Sunday 15 January 2012

swift - AppDelegate, DidFinishLaunchingWithOptions, ImplicitlyUnwrappedOptional What does it mean? -



swift - AppDelegate, DidFinishLaunchingWithOptions, ImplicitlyUnwrappedOptional What does it mean? -

the app build no error in debugging area, stops , bring me this;

i'm not sure create of error. can guess in appdelegate.swift, somewhere along didfinishlanchingwithoptions.

does know how solve error?

sorry, not smart plenty figure out trivial error guys

update:

i've tried suggestion user mstysf below, same problem occur? doing wrong or missing something?

func application(application: uiapplication!, didfinishlaunchingwithoptions launchoptions: nsdictionary!) -> bool { if allow navigationcontroller = self.window?.rootviewcontroller as? uinavigationcontroller { allow challengescontroller = navigationcontroller.topviewcontroller challengesviewcontroller unarchivedatasource() if allow datasource = challengedatasource { challengescontroller.challengedatasource = datasource } else { loaddefaultchallenges() challengescontroller.challengedatasource = challengedatasource } } homecoming true }

does know wrong? again, help appreciated.

it means navigationcontroller nil. should handle this:

if allow navigationcontroller = self.window?.rootviewcontroller as? uinavigationcontroller { // work here }

it builds because compiler trusts navigationcontroller won't nil , not check it. that's point of implicitly unwrapped optional type. in runtime if nil app crashes. that's danger of implicitly unwrapped optionals.

swift appdelegate

No comments:

Post a Comment