0

I decided today to upload my iOS8 app to iTunes Connect to try out TestFlight. That worked fine, until I tapped on one of the tableviews and the app crashed. After half a day figuring out how to debug a released app, I finally was able to pinpoint the crash. To be clear, this only happened on the release version. Debugging never let the program crash here on my wifes phone, my own or any emulator.

The app crashed on the following line:

folderID = folder.folderID as Int

I did that, since folder.folderIDis a NSNumber and I used this method many times before to get something similar done.

My app runs fine now by casting folder.folderID to an Int using:

folderID = Int(folder.folderID)

So my question is not directly how to resolve my bug, but more what could have happened here, since it did not crash while debugging all the time. But now I uploaded the app and tested it on a few devices it crashed here.

And `folder.folderID' only returns whole Integers.

Should I review my previous methods to ensure it might not be crashing material in the future?

Henk-Martijn
  • 2,024
  • 21
  • 25
  • If `folderID` property of `folder` is an `NSNumber`, I'd be inclined to use the `integerValue` method to get the `Int` value. (By the way, if `folder` is implicitly unwrapped, test to make sure it's not `nil`, too.) – Rob Apr 03 '15 at 18:09

1 Answers1

0

One reason could be that folderID is null

Salil
  • 375
  • 1
  • 5
  • 14
  • They cannot be null the way it is setup. At that moment it had a value of 2. – Henk-Martijn Apr 03 '15 at 16:35
  • I think rather than using as, you would be better off using as? You can find more details here http://www.touch-code-magazine.com/swift-optionals-use-let/ – Salil Apr 03 '15 at 16:39
  • I'm aware of optionals and I should do better error handling, but I'm more curious why the program crashes in release more and not in debug. – Henk-Martijn Apr 03 '15 at 17:10