pointers - Error saving NSManagedObjectContext in swift -


i'm using xcodes auto generated code core data swift project includes function in app delegate:

func savecontext () {         if let moc = self.managedobjectcontext {             var error: nserror? = nil             if moc.haschanges && !moc.save(&error) {                 // replace implementation code handle error appropriately.                 // abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development.                 nslog("unresolved error \(error), \(error!.userinfo)")                 abort()             }         }     } 

when have error managed objects instead of printing message details error app crashes exc_bad_instruction error.

in the documentation says:

a pointer nserror object. not need create nserror object. save operation aborts after first failure if pass null.

is app aborting because error nil? bug or expected behavior? (and if it's expected, approach supposed take recover error instead of crashing?)

(i'm running xcode 6.3.1)

edit 1: error @ moc.save function, not abort() - e.g. commenting out abort doesn't stop crash, , nslog never reached.

exc_bad_instruction arghhhh

edit 2 adding screenshots of backtrace (?)

backtrace sadness

i investigated causing error in first place. i'd assumed simple model validation error (trying save object missing required attribute) attributes optional.

it turns out problem transformable attribute trying save array of objects don't adopt nscoding.

i've fixed , tried deliberately causing other types of errors (e.g. model validation) , save function works expected.

shame wasn't getting sensible error transformable thing, glad it's otherwise working, , learning experience!


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -