Questions tagged [swift]

Swift is a general-purpose, open-source programming language developed by Apple Inc. for their platforms and Linux. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [macos], [watch-os], [tvos], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

0
votes
0answers
3 views

How to convert RSA pem file to XML in swift? or How to get RSA XML in swift?

I have a project on who want to generate a public and private key with RSA and I use SwiftyRSA, but it just can export PEM, base64 and data format. Now how can I convert those formate to XML? do { ...
0
votes
0answers
3 views

Failed to load bar-code image to SCNPlane

Got [SceneKit] Error: Failed to load : (0)Create a SceneKit scene by Scene Editor, add a SCNPlane node to this scene to hold an UIImage object (barcode image) (1)Get an UIImage returned from a ...
0
votes
2answers
13 views

Ensure phone number UITextField has a “+” prefix

I have several UITextField where a user can insert phone numbers into it. When I click the send button, it sends an automated message to the numbers listed. Everything works well but what I want to do ...
-1
votes
0answers
7 views

Is there a way to hide/show textField based on UIPickerView Selection?

Issue I am using Xcode 10, Swift 5. I am trying to use one viewController that will display a series of textfields. I only want to display certain textFields based on a category selected in a ...
0
votes
0answers
8 views

CoreImage CIColorClamp adjusting to wrong values

I'm trying CIColorClamp on an image which should just keep pixels within a specified range (https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/...
0
votes
0answers
15 views

Firebase datadescription returns empty array

I'm trying to Grab all Fields as dictionary from 1 document. But when I try to do it i just get returned with empty array. I tried getting help from documentation and it's not working. tho this line ...
0
votes
0answers
19 views

Subclassing multiple classes in IOS

I am a novice in Swift and IOS right now. I am making a React Native app that uses IOS native code written in Swift. These methods in order to be linked to React native need an implementation file. I ...
1
vote
1answer
20 views

Explanation of draw(_:) ios method syntax [duplicate]

What does the (_:for:) syntax mean after the 'draw' text? In particular the underscore and for. I would assume the two colons are meant to represent that the method takes two arguments. I just picked ...
0
votes
0answers
5 views

Can't tap MKMarkerAnnotationView callout if it overlaps with another MKMarkerAnnotationView?

I am displaying a set of annotations on an MKMapView, using a custom MKMarkerAnnotationView with displayPriority = .required so that there is no clustering or hiding, and a UIButton as its ...
0
votes
0answers
10 views

How do I implement a pan gesture to collapse an expanded collectionview cell?

I am working on an app that has a UICollectionView, I made it so that when I tap on a cell in the collection view, it expands to fill the screen and reveals text; when I tap the inside the cell again, ...
0
votes
2answers
20 views

Value of type '[Double]?' has no member 'append'

I have the following problem: Value of type '[Double]?' has no member 'append' My code: var values : [Double]? if (value.string == nil) { values = (dataChart[key])! values.append(Double....
0
votes
0answers
9 views

How to disable the Haptic Feedback when playing a Live Photo

In my app I allow the user to play Live Photos from their photo library. To do this I use the following: @IBOutlet weak var livePhotoView: PHLivePhotoView! @objc func handleTapGesture(_ recognizer: ...
0
votes
0answers
15 views

How can I reduce energy usage from infinite CAAnimation? (Animated Gradient)

I want to include an animated gradient in my application and I'm currently using CATransition for the task. However the animation has very high energy usage on both iOS as well as macOS (I develop ...
0
votes
1answer
9 views

UIWebview inside UICollectionView, how to stop reloading webview on scrolling collection view

I have UIWebView inside UICollectionViewCell, whenever i scroll collection view my webview getting reloaded. It is taking so much time. I kept some booleans to stop reloading webview, if that cell's ...
0
votes
2answers
27 views

Swift exit for loop from within an autoreleasepool?

Assuming I have the following in a loop: for i in 0...10 { autoreleasepool { // do some crazy memory thing } } How would I go about breaking out of the for loop from within the ...
0
votes
1answer
13 views

Pass Data from ViewController > TabBarController>NavigationController>ViewController

I have a login screen that goes to a tab bar, which then transitions to a Navigation Controller. I need to pass the username to the first view controller of the Navigation Controller. so it goes: ...
0
votes
2answers
26 views

Why does cloud functions return ‘Optional()’ with the value

I have a function to check wether an email is in use or not, here’s the code for the function: import * as functions from 'firebase-functions' import * as admin from 'firebase-admin' admin....
0
votes
1answer
23 views

app's CRUSHING when I click 'SAVE'… any ideas?

i have a memories write app and in that app you can create memories that contain title, body, pic and date (there is a countdown til the date). it was working fine until i added those date-relate code ...
0
votes
0answers
7 views

Prevent VoiceOver From Reading UIButton as “Possible Text”

I am writing a very simple game that is designed specifically for blind users, but may also be used by sighted users. It uses many buttons as elements, however, blind users interact with these ...
0
votes
2answers
24 views

Can't set a variable to the value of a textfield

I'm trying to get the text value of a UITextField, convert it to a Double, and save it to a variable. However, I'm getting the error: Expression type '@lvalue String?' is ambiguous without more ...
0
votes
1answer
29 views

Programmatically set constraint priority

I have a requirement to recreate a .xib based layout programmatically. I have largely been able to achieve this, however, cannot set the priority of one of my anchors. The setting I am trying to ...
-1
votes
0answers
27 views

Subclassing multiple classes in an interface in Swift

I am making a React Native app, where I need to write some native code in iOS. This is my swift file code which has events that need to be dispatched to React Native func locationManager(_ manager: ...
0
votes
0answers
7 views

Embedded Tweet doesn't load completely sometimes in WKWebView

I'm trying to load some embedded tweets in WKWebViews in Swift, on iOS. I get the html content with Twitter oembed API (https://developer.twitter.com/en/docs/twitter-for-websites/embedded-tweets/...
0
votes
0answers
12 views

View elements not showing when mixing programmatic and IB design

forgive me if I am positing in the wrong place, I am new to the forum and to Swift/Xcode I am trying to mix programmatic code and IB elements. This all works fine and I can add buttons etc to it as ...
0
votes
0answers
16 views

Cannot use instance member 'today' within property initializer; property initializers run before 'self' is available [duplicate]

Trying to create Date variables need to create date variables representing the previous 5 days, the current date and the next five days for a pickerView var today : Date = Date() var tomorrow = ...
0
votes
0answers
6 views

Collectionview the end Draging Position dont stop on each cell

could somebody help me? I have Collection view with insets, Scroll Direction Horizontal, Paging enables and no space between cells. And the issue is that the paging doesn't stop on each cell. I tried ...
0
votes
1answer
24 views

How search for a file/folder by a string query in OS X?

Like Finder, you give it a string query and it returns a list of files with the matching string, I do not want to use the other method of getting all the files in a directory and then iterating it one ...
0
votes
1answer
27 views

Firebase Facebook Login - Detect User login status and redirect

I'm trying to create a login page for an app that uses the Facebook Login SDK. When the RootViewController loads, it should determine if the user has already logged in via Facebook and if so, direct ...
0
votes
3answers
61 views

How to get all true values

I have a Firebase structure like this: "userObjects" : { "fP8g5kxrjnBhYTiUxjF6Pdc5xfgP" : { "objectsInLists" : { "603648351" : { "Top" : true }, ...
-2
votes
1answer
30 views

let future = sender.date - what type is FUTURE?

can somebody tell me what is the type of "future" in this code below? @IBAction func datePickerChanged(_ sender: UIDatePicker) { let future = sender.date //Use midnight today as the starting ...
1
vote
1answer
44 views

Call own function with a completion handler

I have a method to create an account: func createAccount (completion: @escaping (_ succes: Bool, _ message : String)->()) { Auth.auth().createUser(withEmail: createMail(), password: ...
0
votes
0answers
10 views

rxSwift Pagination tableView

I can't add pagination for tableView.when i have more item so need pagination when scrolling bottom side and when i scroll back my cells don't disappeared. I dont know how can i do this my codes under ...
2
votes
1answer
42 views

Unable to conform to a protocol using another conforming protocol [duplicate]

I came across the following code and am not sure why it doesn’t compile: protocol CellDelegate: class {} protocol DelegatingCellViewModel { var delegate: CellDelegate? { get } } protocol ...
0
votes
1answer
31 views

Convert a swift sorted method to objective-c

What is the best way to convert this objective-c sorting method? let visibleViews = self.scrollView.visibleViews().sorted(by: {$0.frame.origin.x > $1.frame.origin.x} ) I convert to : [...
0
votes
0answers
19 views

Swift: How to make UITableView with dynamic cell sizes appear in UIStackView?

I am trying to place a UITableView with self-sizing cells in a UIStackView. The UITableView's isScrollEnabled property is set to false. The UITableView is then added to a UIView, this UIView is added ...
-2
votes
3answers
27 views

Enum Type: Int / Expected identifier after comma in enum 'case' declaration

I have a model for my UISegmentedControl. I have an error on my enum and I don't know what it is. In my SegmentedControl I want to have for : Index 0 = 1(Int) Index 1 = 2(Int)..... My code and my ...
0
votes
3answers
58 views

Button title gets cropped on click

I have a dropdown menu for the user to be able to change the displayed data. When the user chooses to select an item, among others a button is being updated. Let's say in the beginning the buttons ...
0
votes
2answers
30 views

Basic code that counts the number of digits in a given number, but why is it working?

I wrote this function but, while I'm happy it works, I don't seem to understand why. This function just give us the number of digits in a given number passed in it. My question is: Since I'm only ...
0
votes
0answers
42 views

How do I make sure that callbacks are performed one after another in Swift? [duplicate]

I have a method that sorts items which come from two different sources and puts them into the tableView, both sources are called at the same time and can return results independently, how do I make ...
0
votes
2answers
73 views

Swift check if NSNumber is Double

So I'm trying to check whether NSNumber is Double or Int and I'm wondering if it's even possible. I was hoping this will work, but it always returns true no matter with which type I'm comparing var ...
0
votes
1answer
47 views

How do I sort a 2 dimensional array columns in Swift based on the values in a row?

How can I sort a two dimensional array based on values in one of the rows? let array = [["X", "Y", 1, 2, 3, 4, 5], ["V", "W", "A","B","C","D","E"] ] let sorted = [["X", "Y", 5, ...
0
votes
4answers
39 views

How to store json response into variable?

I am getting json response from api. I need to store into variable using model,how can i store? struct StructLogin { var status:String? var contentarr = [content]() } struct content { var ...
0
votes
1answer
20 views

How to work with Single Sign In using WKWebView in Swift iOS?

I want to sign in using URL in WebView and on Success login it should redirect to my App with print of user info, token etc. Please help with sample code or step by step full code structure: ...
0
votes
1answer
17 views

Can I create an NSColor with code so that it can change according to dark mode or light mode?

I can create such a color in Xcode asset management, of course it takes more than 10.13 to be applied. I'm currently adding theme functionality to my app, and I think it might be helpful to code an ...
0
votes
1answer
20 views

Pass Data From ViewController to TabBarController

I need to pass a username from the View Controller login screen to by Tab Bar Controller textfield. I have tried the traditional method of doing this and am receiving a "Could not cast value of ...
0
votes
2answers
27 views

Can't observe UIPageControl's currentPage changes in Swift

I've a subclass of UIPageControl, and I'd like to observe the changes in currentPage. Unfortunately, my currentPage's didSet isn't called when currentPage changes from taps on MyPageControl. class ...
0
votes
0answers
13 views

How can I get the frame of one of the x-axis labels in the horizontal bar chart of Charts?

I've created a bar chart by using the Charts framework. Currently, I'm trying to draw a red circle underneath the current day. However I'm not able to get a reference to the bounds nor the frame of ...
0
votes
0answers
40 views

Passing data between viewControllers in MVVM

I am having trouble with passing data from my collectionViewController to detailViewController. I am trying to learn MVVM now and it's kinda confusing to me. In MVC it's quite straight forward but in ...
0
votes
3answers
34 views

Send array of objects in alamofire

I need to to send a list of objects to an end point. the required type has the following keys { id: Int; all: Bool; batch: Bool; chapter: Bool; myNetwork: Bool; categoryId: Int; } the ...
0
votes
0answers
17 views

Mac OSX save image programatically in Photo Booth in Mac

I want to save image programatically in photo booth app in mac. is there any possible to do this?any help will be appreciated.