Tag: swift

How can i compare two dates (NSDate) in Swift 3 and get the days between them?

How can I compare two dates in Swift 3? I found many solutions for other Swift versions, but they doesn’t work for me. let clickedDay:String = currentcell.DayLabel.text! let currentDate = NSDate() let currentDay = “” //want the current day let dateFormatter = DateFormatter() var dateAsString = “” if Int(clickedDay)! < 10 { dateAsString = “0” […]

Crash in openURL: Possible Facebook SDK bug in iOS 9

Context I am using the FBSDKLoginButton with my app. I am on Xcode 7.0 and my iPhone is running iOS 9 beta 3. I followed every step showed by Facebook (creating the app, etc) and followed the steps for adding the button as in https://developers.facebook.com/docs/facebook-login/ios#login-button. As I am on iOS 9, I had to add […]

Xcode 6 adds two dots (periods) when coding in Swift for prediction

Whenever I am typing and want to access functions for a specific object, Xcode adds a second dot after the first one that I have typed. This is frustrating because I have to manually remove one of them every time. Is there a way to change this?

Adjust height of UILabel dynamically using iOS storyboard

I have a label, which has been created using iOS Storyboard layout. Contents of label, however, are dynamic and can change during run time. How do I make sure that label’s height gets adjusted based on the content in the label. I tried: Setting number of lines to 0 Setting Editor -> Size to Fit […]

Resize label to fit text amount – Swift

Hey 🙂 I have a label and I need to make the width of that label smaller or larger accourding to the text amount, and I found only how to adjust the text to fit the size but the how to adjust the size to fit the text, any ideas ?

How to change the state of an UIButton in iOS using Swift?

I have Objective-C working code for six buttons but I don’t seem to find how to change the state of a button using Swift. So how do I make the following code work in Swift? [self.button2 setBackgroundImage:[UIImage imageNamed:@”button2_selected.png”] forState: UIControlStateSelected]; button1.selected = NO; button2.selected = !button2.selected; button3.selected = NO; button4.selected = NO; button5.selected = NO; […]

Swift & Objective-C project – generated -Swift.h error – Cannot find interface declaration for UIViewController

I’ve got a project using the Swift generated Bridging Header and have the project set up correctly (no spaces in Names, Uses Modules, pre-declaring Swift classes in my .mm file, Deleting derived data, doing a clean rebuild etc…). The Bridging Header is being generated fine, but the automatically generated -Swift.h has errors in it. What’s […]

How to prevent the Apple Watch from going to sleep?

We are working on an Apple Watch project, but the watch goes to sleep if uninterrupted with. Is there any way to prevent it from going to sleep?

XCTAssertEquals with two dicts in Swift

I am doing the exercism.io programming exercises and the tests I have to perform on my code has the goal to compare to dicts with each other. The sourcecode of the exercise can be found here https://github.com/exercism/xswift/tree/master/word-count As of what I have understood bridgeToObjectiveC is apples internal methods for doing things and therefore they have […]

Swift: Thread 1: signal SIGABRT

This is my second project that I’m doing in Swift 3. I ran into this error code: Thread 1: signal SIGABRT and my project won’t load correctly either. Please help! Img: UPDATE: WORKS NOW!