2014-11-01 99 views
0

该应用程序在调试区域成功建立并没有错误,但立即停止并将我带入此处;AppDelegate,DidFinishLaunchingWithOptions,ImplicitlyUnwrappedOptional这是什么意思?

error message

我不知道做了错误的东西。我只能在AppDelegate.swift中,在DidFinishLanchingWithOptions的某个位置猜测它。

有谁知道如何解决这个错误?

对不起,没有足够的智慧这可能微不足道的错误找出给你们

UPDATE:

我试着用以下的用户mstysf的建议,但同样的问题发生?我做错了还是错过了什么?

func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { 

    if let navigationController = self.window?.rootViewController as? UINavigationController { 

     let challengesController = navigationController.topViewController as ChallengesViewController 

     unarchiveDataSource() 

     if let dataSource = challengeDataSource { 
      challengesController.challengeDataSource = dataSource 
     } else { 
      loadDefaultChallenges() 
      challengesController.challengeDataSource = challengeDataSource 
     } 
    } 
    return true 
} 

有谁知道什么是错?再次感谢,任何帮助表示赞赏。

+0

看起来像我的'let challengesController = navigationController.topViewController作为ChallengesViewController'需要解包或什么?我不确定。 – 2014-11-02 04:41:43

回答

0

这意味着navigationControllernil。你应该用它处理这样的:

if let navigationController = self.window?.rootViewController as? UINavigationController { 
    // do your work here 
} 

它成功地建立,因为编译器相信你navigationController不会nil,不检查。这是隐式解包可选类型的一点。在运行时,如果它是nil那么你的应用程序崩溃。这是隐性解包选择权的危险。

+0

感谢您的帮助,我仍在学习过程中。 我试过你的建议,但同样的问题发生? – 2014-11-02 00:40:35