问题
I have the following simple code in NSAppDelegate
func applicationDidFinishLaunching(aNotification: NSNotification) {
var opt:Int?
NSLog("\(opt)")
NSLog("\(opt!)")
NSLog("done")
}
Now when I run that in debug mode it tells me what we all know about unwrapping nil optional. But when I run that for release it silently exits the app with no message at all. No console log. No dump. Nothing!
What's going on here?
回答1:
Apple has asked me to check if the bug has been fixed with Xcode 6.3 beta 3 with Swift 1.2 (Build: 6D543q). Not sure if I really want to test another beta :-/ However, the answer to my question: it's a bug.
Edit Jumped over my own shadow and tested with the last beta (4). Issue has been fixed.
来源:https://stackoverflow.com/questions/29143855/nil-optional-does-not-crash-in-release