Nil optional does not crash in Release

故事扮演 提交于 2020-01-16 18:00:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!