Questions tagged [swift3]

Use this tag only for questions directly related to changes in version 3 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc for questions about developing on Apple platforms.

swift3
Filter by
Sorted by
Tagged with
0 votes
1 answer
146 views

Cannot update calendar firstWeekDay Swift 3.0

I'm trying to update the calendar firstWeekDay to something else (as far as I seen the default firstWeekDay is Sunday) but some errors occur. private var calendar = Calendar.autoupdatingCurrent ...
Robert Basamac's user avatar
1 vote
1 answer
433 views

How to read CoreML model Prediction MLMultiArray

I am new to CoreML and I have generated a coreML model that return the Double 9 × 4 matrix matrix as shown in image blow. Here is the code that is working fine and giving me the MLMultiArray. let ...
Qazi Ammar's user avatar
  • 1,282
0 votes
1 answer
90 views

Update individual item in the array swift

I have an array like this. How do I update the individual var when I update the array? var value1 = 1 var value2 = 2 var value3 = 3 var array = [value1, value2, value3] array[0] = 0 This will update ...
Tim Nguyen's user avatar
1 vote
3 answers
3k views

SwiftUI ForEach index jump by 2

I am working on SwiftUI ForEach. Below image shows what I want to achieve. For this purpose I need next two elements of array in single iteration, so that I can show two card in single go. I search on ...
Qazi Ammar's user avatar
  • 1,282
0 votes
0 answers
56 views

Identifier sqrt not detected

When I was calculating a square root of a number in my command line using sqrt(newValue) it gave back the error Use of unresolved identifier "sqrt". Is there a new Operator for this or why ...
korraa's user avatar
  • 1
0 votes
2 answers
72 views

Is there any option to remove ALL warning of was written to, but never read/Used?

Im working on maintained of large project. there is lots of warning(790+). most of theme are ** "variable was written to, but never read/Used". ** i tried one by one fixed but its take ...
Dhaval Umraliya's user avatar
0 votes
1 answer
55 views

Replace Gradient colors with ThemeSwift library (Library used for App Theme management)

How to use this library for gradient colors as they haven't mentioned the usage of gradient with ThemeAnyPicker in their documentation. I am using plist method which is much easier way than the other ...
Jaseel.Dev's user avatar
0 votes
1 answer
828 views

Swift - Filter json response based on if it contains a certain key

I am wondering if I can filter a response from an API request based on if an item in the array contains a certain key. I want to filter the array so that I only have instances of dictionaries that ...
Papi's user avatar
  • 325
0 votes
1 answer
177 views

Facing issue while trying to init the pods on project

I hope you all are doing well. I'm facing issue while trying to init the pod in the project. Cocoapods is already installed in the system. XCode Dev intstall is also there, In XCode in command line ...
Adnan Khan's user avatar
0 votes
2 answers
222 views

What is wrong with this API call for SwiftUI

I have been trying to make an API call with swiftui, but I keep running into threading errors when I run the code. This is the current program: import SwiftUI struct Post: Codable, Identifiable { ...
user18263931's user avatar
0 votes
1 answer
267 views

How to use Button SwiftUI correctly?

There is a code that, by pressing the "Sign Up" button at the bottom of the screen, should open another window. But for some reason, when you click on the button, no action occurs. I need ...
Не человек и не кот's user avatar
0 votes
2 answers
2k views

How to pass data into header while using URLSession in Swift?

I am new to swift and am in the learning phase. I have to basically make a request using URLSession but the API does not allow any unauthorized requests here is my code : func getCoinPrice(for ...
Junaid Tariq's user avatar
1 vote
0 answers
186 views

Is there a way to set global settings for all Swift Package Manager dependencies?

I added GoogleSignIn with SPM however, I get 2 warnings (See attached). I know that the issue has to do with the values set on the Package.swift file of the dependency. I have been browsing around to ...
JLico's user avatar
  • 25
1 vote
1 answer
1k views

swift: is there any way to Download a language pack to give offline translation feature

I'm trying to give a feature like google translate app where user can download multiple languages and see translations in those. More specifically, I need to implement offline language translation. ...
Uzair Mughal's user avatar
0 votes
1 answer
24 views

Fix sidemenu bar logo display in swift

the swift code below allows you to view a side menu my problem is this, the first element of the menu is an image (attached) now the problem lies in the fact that in the image there is a space to the ...
riki's user avatar
  • 1,645
0 votes
1 answer
41 views

compilation error when trying to create a new array

Can you help me with 1 question please? I have erorr while try to create new array Error text: "Cannot use instance member 'images' within property initializer; property initializers run before '...
shabay88's user avatar
1 vote
0 answers
314 views

How can I draw a view on top (z axis) of another, without using ZStack? In Swift/SwiftUI

So I have this problem (see image to have a clearer idea). I have a something like this: NavigationView { VStack { Spacer() HStack {} Divider() List{} } ....
MCRG's user avatar
  • 11
-1 votes
2 answers
632 views

Unwrapping an Optional value in swift and realm

I wrote a working function for the application, but the error came out "The nil value was unexpectedly found when an optional value was implicitly deployed" limit Limit label.the text I can'...
ruzaykina's user avatar
0 votes
1 answer
279 views

Change UIActivityViewController Subview Background colour SwiftUI

I'm trying to change UIActivityViewController subview background colour means when UIActivityViewController open and then user click on reminder the reminder background colour automatically change. i ...
Sham Dhiman's user avatar
  • 1,478
0 votes
1 answer
961 views

IndexPath.row of CollectionView gets changed while scrolling

I am new in swift, the issue I am facing is I have a collection view of height 2000. when I scroll down to the bottom, the indexPath.row gets changed due to which the logic gets disturbed. I ...
hussain's user avatar
  • 799
4 votes
1 answer
3k views

"Unable to infer type of a closure parameter 'b' in the current context". Getting this error while calling the function

getting error while calling the function. func hitService<T : Codable>(urlS: String , completion : @escaping (T) -> Void) { guard let url = URL(string: urlS) else {return} ...
Rajat Dhasmana's user avatar
0 votes
0 answers
50 views

Can 8 bytes be NIL?

I am trying to build a BLE packet that contains a RGB color and !C to ID the packet type, using the built-in color picker and some math it works well to get the RGB values and converting the Int to ...
TheBrewery's user avatar
-2 votes
1 answer
719 views

How to use removefromsuperview()?

I want to remove self.view.subviews in UI interface. I tried with view.removeFromSuperview(), It removes entier UI view.
DHANA_Nagarajan's user avatar
-3 votes
2 answers
2k views

Add SwiftUI on a UIView which is Inside of a UITableViewCell [duplicate]

How can I add SwiftUI on a UIView which is Inside of a UITableViewCell, usually with uihostingcontroller SwiftUI view can be added to a ViewController as child but how can we do this on a ...
Sadman Samee's user avatar
0 votes
0 answers
121 views

XCode: Can't compile StoryBoard (ibtool exit code 10) for an old project - swift 3 and pods

Hi there and thanks for your time in advance. A project have been passed to me via bitbucket to be reuploaded to App Store cause they are removing old projects. My plan is to switch to swift 4 and ...
josecash's user avatar
  • 339
-1 votes
1 answer
420 views

Disable RTL on specific UIViewController in iOS

Is there any way to disable Right-to-Left in specific ViewController? I have tried forcing semanticContentAttribute to Left-to-Right but it is not working. self.view.semanticContentAttribute = ....
Muhammad Haroon Iqbal's user avatar
2 votes
1 answer
699 views

how to decode a json to an struct/class object having space in their keys? [duplicate]

Hello I have a json object like this { "ID NATION": "US" "ID YEAR" : "1995" } I am trying to convert it in to an struct object in swift struct ...
Sri's user avatar
  • 25
0 votes
1 answer
498 views

When Firebase analytic events are triggered?

I am using firebase analytic events to get user event updates, but there is a scenario where I need the user info without been tapped on any button. So I tried but noting is getting displayed in xcode ...
supreet's user avatar
  • 21
0 votes
1 answer
441 views

How to get the url path of Apple ODR resource?

I am new in Xcode and Swift. Currently working on a script dealing Apple's ODR: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/Managing....
inoxious's user avatar
  • 313
-3 votes
1 answer
212 views

How to sort array of UIImages?

I have 3 images, I need to implement them with animation. How i can display each image separately on the screen using a loop? help me please class ViewController: UIViewController { var imageArray:...
shabay88's user avatar
0 votes
0 answers
112 views

failedToFetch error in swift (IOS) firebase

I am trying to fetching conversation from firebase but it's showing failedTofetch data. It is fetching from firebase but in guard let statement it fails. On successful i get a 2D array but on failure ...
shashwat singh chauhan's user avatar
0 votes
0 answers
91 views

UIAlertController presenting and dismissing based on internet connection crashes when on cellular data

I have a strange crash on my app, I created a NWPathMonitor pathUpdateHandler to check for network connection. Inside the pathUpdateHandler, I added two conditional statements based on the network ...
Mr Astronaut's user avatar
0 votes
1 answer
283 views

Remove the existing string and append a new string for that string

I have a video URL like this urldomain.com/livestream_id/PLAYER_WIDTH&PLAYER_HEIGHT&IDFA_ID&DEVICE_ID If the video URL contains the PLAYER_WIDTH&PLAYER_HEIGHT so I have to replace ...
kuldeep bhandari's user avatar
2 votes
1 answer
681 views

Set the maximum amount limit on a UITextField in Swift

I know how to put character length limit on UITextField. But I am looking for an idea how to put amount limit on UITextField so that it can not take more than that limited amount. I want to put limit ...
Ashwani Kumar's user avatar
4 votes
1 answer
988 views

Delete a Binding from a list in SwiftUI

I am trying to simply delete an element from a list in Swift and SwiftUI. Without binding something in the ForEach loop, it does get removed. However, with binding something it crashes with an error ...
FloWy's user avatar
  • 974
2 votes
1 answer
129 views

Managing Dynamic Keys in response through Codable Protocol

I need to make the codable model for the dynamic keys of dictionary coming from response below is the response I'm getting. { "data" : [ { "desc1" : ...
Adnan Khan's user avatar
2 votes
2 answers
626 views

SWIFT - Setting layer.cornerRadius greater than the view height causes issues

I actually want to add a corner radius to a view on only one side. The radius is supposed to be of full height. This is my implementation. someView.layer.cornerRadius = someView.frame.size.height ...
Faran Rasheed's user avatar
0 votes
1 answer
1k views

Cannot convert value of type '<Int>' to expected element type <Any>

I'm trying to learn swift, but I have a problem where using <Object> in Java would fix my problem I think, and the Apple doc says I should use <Any> but I keep getting errors. I'm trying ...
Alejandro Rosales's user avatar
0 votes
1 answer
2k views

Cannot convert value of type 'UnsafePointer<T>' to expected argument type 'UnsafePointer<Int16>'

I am trying to manually convert Swift 3 code to Swift 5, but am getting error when trying to cast memory. let buffer: UnsafePointer<Int16> init<T>(buffer: UnsafePointer<T>) { ...
Deepak Sharma's user avatar
0 votes
0 answers
76 views

I'm facing problem decoding a HTML script as string value from JSON, every other value is being converted just fine

I'm working with a JSON response where the value of a key contains HTML as string, it's not very large still it's not decoding. Here is my JSON Response { "authentication": { &...
mehed1hasan's user avatar
1 vote
1 answer
293 views

File importer/ File Mover methods are not getting invoked when using Form swift UI

even though the binding properties in fileMover are set to true. file mover is not getting executed. Below is the sample code i have used. Any leads will be helpful. Thanks in advance. var body: ...
sharath kumar's user avatar
0 votes
2 answers
1k views

Uitableviewcell border

I have set of uitableviewcell . I want to apply border color for the following conditions Applying top border color for firstcell And bottom border color for lastcell. I'm new to swift so I'm not sure ...
Crist's user avatar
  • 39
1 vote
2 answers
1k views

Reload tableview without scroll

I am new to swift I want to reload my tableview so I used tableviewName.reloadData() After this the table view is reloaded and scrolled a bit upwards but I want to stay where it is Here is the code ...
Crist's user avatar
  • 39
-1 votes
1 answer
173 views

how in the numberOfItemsInSection method to return the number equal to the value that I set in the slider from another view controller in Swift?

I am still learning swift, and I am trying to create a UICollectionView that would return the number of items that I set in the initial view controller using the slider, but my code doesn't work, how ...
Alim Kuprianov's user avatar
28 votes
4 answers
14k views

Observing "App needs to be updated" message when launching app on iOS 15

We are trying to test application on iOS 15 and found that we are getting this message App needs to be updated. Can anyone please let me know the reason behind this message? Existing users will have ...
Ankush Dhawan's user avatar
0 votes
1 answer
154 views

How to make a synchronous API call which is nested inside another API failure callback in Swift

In getRatingReviewFromServer(), if I get success everything is fine, but if I get failed I need to call another API refreshToken() if I get success on refreshToken() call I will call ...
A_Rush's user avatar
  • 378
1 vote
1 answer
1k views

Buttons in a subview not working with SwiftUI

I have this subview declared here: import SwiftUI struct NavigationBarView: View { @State private var showingMenu = false var body: some View { HStack { Button(...
meep's user avatar
  • 31
4 votes
1 answer
625 views

Mask over the image view Swift 5

I have been trying to implement this answer from this question using Swift 5.2 I only see the blurred image and the mask is not appearing. Can someone point me what I am missing there or how to ...
Anita's user avatar
  • 2,951
0 votes
1 answer
59 views

Why is my image quality decreasing when setting the radius and size?

I am using the following methods in a UIImage extension to use an image from a URL and displaying it as a UIBarButtonItem. However, when I use the following to adjust the corner radius and size, the ...
helloworld12345's user avatar
3 votes
1 answer
212 views

Do you need to call super.prepareForSegue:?

I am following the Apple Books for learning. I am currently working with table view and segues. I got this piece of code: override func prepare(for segue: UIStoryboardSegue, sender: Any?) { super....
Sergio Novoa's user avatar