ios - Swift/CoreData - Variable reference changes after initializing -
i'm getting feet wet coredata using swift , coming across doesn't make sense me.
basically i'm building simple map app user can drop pin, select info button annotation view, , add location "favorites" list. want keep list between sessions.
i have in appdelegate:
func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { // override point customization after application launch. self.datacontroller = datacontroller() return true }
datacontroller() code located deals with....you guessed it. data. have init() , 1 other function adds data.
this code takes info , uses function in datacontroller class add data data set
let defaultaction = uialertaction(title: "ok", style: .default, handler: { (action) -> void in let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate appdelegate.datacontroller.additemtodata(self.locationinfo.address, city: self.locationinfo.city, zip: self.locationinfo.zip, country: self.locationinfo.country, latitude: self.locationinfo.lat, longitude: self.locationinfo.long) })
this gets weird. screenshot when app on "let appdelegate =...."
and when app running next line down
appdelegate.datacontroller....
as can see images, datacontroller has value @ first, when try use 1 line down equals nil , appdelegate has different value. app errors out "fatal error: unexpectedly found nil while unwrapping optional value" because of that. has else seen or know may going on?
Comments
Post a Comment