Tag: swift

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!

Warning: Attempt to present <GuessMeFinal> on <GuessMeFinal.ViewController> whose view is not in the window hierarchy -Swift

Okay..here’s the problem. When I click the [Play] button in the main menu, it should go to the corresponding ViewController according to this code: @IBAction func playButton(sender: AnyObject) { if rightCounter <= 4 { if let Level1 = self.storyboard!.instantiateViewControllerWithIdentifier(“Level1”) as? Level1 { self.presentViewController(Level1, animated: true, completion: nil) } } if rightCounter >= 5 && rightCounter […]

How can i disable in a Xcode project that a keyboard appears when i touch in a TextField?

Im a bit new in creating a xcode projects, so i have a program that i need to press the TextField to insert some values, but I don’t want to do that with the native keyboard but only with the buttons that I will create, like a calculator. I already explore some definitions and i […]

NSTimer: floating point value can not be converted to UInt8 because it is greater than UInt8.max

My code returns the error: fatal error: floating point value can not be converted to UInt8 because it is greater than UInt8.max. The code is being called when a button is pressed (in a different swift file) but I know that the problem wasn’t with calling the function so I didn’t include it. code: //starts […]

Draw a line that can stretch like the Xcode assistant editor in Swift

When it comes to drawing lines in Swift, most solutions out there are to override the drawRect function in a UIView, but I’m looking for a more dynamic way to draw a line. I have a button, and I want to be able to drag from this button to the next. While dragging, I would […]

Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use '!'

My code was working well in Xcode 6. But, after updating to Xcode 7 I got nearly 20 errors and 50 warnings.This might be some syntax change in Swift 2 Solved all those but can’t figure out this one : Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use ‘!’ let […]

iOS 8 Self Sizing Cells – Allow Zero Height

I am using the self sizing cell feature and it works well until I want to hide a cell completely. I moved away from heightForRowAtIndexPath for this and I setup the following: override func viewDidLoad() { self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 0 } However when I have no text for a tableviewcell to render I […]