I'm using an archived object to determine which view needs to load on startup (or just opening the app from sleep) with boolean flags. Although my if statements evaluate correctly, the code within them does not.
Here is what's in didFinishLaunchingWithOptions:
// Register permission to throw notifications
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert | .Badge | .Sound, categories: nil))
var so = StatusOverseer.sharedOverseer
println("User did finish application: \(so.userDidFinishApplication)")
println("Banks Did Respond: \(so.banksDidRespond)")
println("user did accept terms: \(so.userDidAcceptTerms)")
// Decide whether or not to present the waiting view
if so.userDidFinishApplication && !so.banksDidRespond {
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewControllerWithIdentifier("submitWaiting") as! UIViewController
UIApplication.sharedApplication().keyWindow?.rootViewController = vc
}
else if so.banksDidRespond {
println("bip")
let sb = UIStoryboard(name: "Main", bundle: nil)
if so.notificationWasGood {
let vc = sb.instantiateViewControllerWithIdentifier("approved") as! UIViewController
UIApplication.sharedApplication().keyWindow?.rootViewController = vc
}
else {
let vc = sb.instantiateViewControllerWithIdentifier("notApproved") as! UIViewController
UIApplication.sharedApplication().keyWindow?.rootViewController = vc
}
}
else if so.userDidAcceptTerms {
println("Did Run")
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewControllerWithIdentifier("LicenseViewNav") as! UIViewController
UIApplication.sharedApplication().keyWindow?.rootViewController = vc
}
And here's the console output:
Recalling Status Overseer from Archive...
User did finish application: false
Banks Did Respond: false
user did accept terms: true
Did Run
Notice that the bottom else if
ran as supposed to but the view I see on startup is not LicenseViewNav
as declared in the lines:
let vc = sb.instantiateViewControllerWithIdentifier("LicenseViewNav") as! UIViewController
UIApplication.sharedApplication().keyWindow?.rootViewController = vc
If anyone knows what's going on, that'd be great. Thanks!
Edit: Current Problem seems to be that keyWindow
evaluates to nil