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.
18,461
questions
-4
votes
0
answers
33
views
NavigationBar is not showing (swift)
am new on swift an am trying to make chat app without using storyboard first I wanted a logout button on screen. I assigned UINavigationController as a rootViewController to window.rootViewController ...
0
votes
0
answers
36
views
Swift code example to post a IFormFile to Asp.Net Core 5.0 Api
Can anyone please suggest a swift code example to send a file to the below asp.net core method? Actually, file is being uploaded correctly from the postman, swagger but it is not working via swift. ...
0
votes
0
answers
21
views
Google Nearby Messages API SwiftUI Error "UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController!' [duplicate]
I'm trying to integrate Google nearby messages Api into my application but I'm getting the error "UIAlertView is deprecated and unavailable for UIScene based applications, please use ...
0
votes
0
answers
13
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
...
0
votes
1
answer
22
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 ...
0
votes
1
answer
39
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 ...
1
vote
2
answers
109
views
SwiftUI ForEach index jump by 2
I am working on SwiftUI ForEach. Blow 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 ...
0
votes
0
answers
29
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 ...
0
votes
2
answers
32
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 ...
0
votes
1
answer
23
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 ...
0
votes
1
answer
80
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 ...
0
votes
0
answers
28
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 ...
0
votes
2
answers
59
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 {
...
0
votes
1
answer
47
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 ...
0
votes
1
answer
192
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 ...
0
votes
0
answers
40
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 ...
1
vote
1
answer
130
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. ...
0
votes
1
answer
17
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 ...
0
votes
0
answers
34
views
Wrap pdf vertically in swift
I have few pdf files where the person who reads has to zoom in and pan around to move to next paragraph.
Is there anyway i can view pdf in PDFKit or Webkit by just wrapping the texts in pdf and ...
0
votes
1
answer
37
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 '...
1
vote
0
answers
61
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{}
}
....
-1
votes
2
answers
123
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'...
0
votes
1
answer
70
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 ...
0
votes
1
answer
84
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 ...
0
votes
0
answers
37
views
LPLinkView not loading
I want to display a preview of posts shared from Instagram to my app. I am using the below code to load the Rich link preview inside the table view cell.
self.provider = LPMetadataProvider()
self....
1
vote
1
answer
113
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}
...
0
votes
0
answers
35
views
Is there a way to resolve MPMediaItem.enumerateValues crash when the requested property is missing?
I am getting a crash (EXC_BAD_ACCESS) in MPMediaItem.enumerateValues when the requested property is missing on the media item. The crash occurs in swift_getObjectType
I can work around this by using ...
0
votes
0
answers
35
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 ...
-2
votes
1
answer
43
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.
-3
votes
2
answers
306
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 ...
0
votes
0
answers
19
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 ...
-1
votes
1
answer
130
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 = ....
1
vote
1
answer
148
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 ...
0
votes
1
answer
44
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 ...
0
votes
0
answers
92
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....
-3
votes
1
answer
72
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:...
0
votes
0
answers
17
views
it is possible to add and hide buttons within the video call with Google WebRTC with swift
It is possible to add and hide buttons that are shown within the WebRTC type video call, currently I only have 2 buttons but I can't find a way to hide it and add more buttons for example to mute the ...
0
votes
0
answers
52
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 ...
0
votes
0
answers
89
views
Custom NavigationBar in swiftUI like Apple Music
Hello I'm new in SwiftUI and I traying to make this :
Apple Music Profile
I searched everywhere on the web but I couldn't find anything that could help me, except for UIKit which doesn't work
0
votes
0
answers
55
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 ...
0
votes
1
answer
53
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 ...
1
vote
1
answer
99
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 ...
3
votes
1
answer
226
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 ...
0
votes
0
answers
24
views
Call a view after infoWindowTap in GMSMapView
I want to call a view when i click the marker's info window in GMSMapView.Here is my view code
struct MyView: View {
var body: some View {
//my code
}
}
And i am trying to call the ...
2
votes
1
answer
38
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" : ...
2
votes
1
answer
59
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
...
0
votes
1
answer
453
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 ...
0
votes
1
answer
436
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>) {
...
0
votes
0
answers
49
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": {
&...
0
votes
1
answer
132
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: ...