osx - CoreData auto-generated swift code error -



osx - CoreData auto-generated swift code error -

i'm new swift , core data. i've created simple os x application using core data. in appdelegate.swift there lot of auto-generated code. want save name , lastname when press button in mainmenu.xib i've been searching around while on how utilize core info in os x application using swift no success. code:

@ibaction func buttonaggiunginewdipendentepressed(sender : anyobject) { println("button pressed popover"); //var appdel:appdelegate = (nsapplication.sharedapplication().delegate appdelegate) allow context = self.managedobjectcontext! var nome = popaggiungidipendentenome.stringvalue; var cognome = popaggiungidipendentecognome.stringvalue; var newuser = nsentitydescription.insertnewobjectforentityforname("dipendenti", inmanagedobjectcontext: context) nsmanagedobject newuser.setvalue(nome, forkey: "nome") newuser.setvalue(cognome, forkey: "cognome") context.save(nil) popover.performclose(true); }

i'm getting next crash: thread 1: exc_bad_instruction (code=exc_i386_invop,subcode=0x0) within auto generate code in appdelegate.swift:

var managedobjectmodel: nsmanagedobjectmodel? { // creates if necessary , returns managed object model application. if allow mom = _managedobjectmodel { homecoming mom } allow modelurl = nsbundle.mainbundle().urlforresource("elencotelefonicoakhela2", withextension: "momd") _managedobjectmodel = nsmanagedobjectmodel(contentsofurl: modelurl) homecoming _managedobjectmodel! } var _managedobjectmodel: nsmanagedobjectmodel? = nil

when tries homecoming managedobjectmodel. idea? thanx in advance

instead of insertnewobjectforentityforname use:

let en = nsentitydescription.entityforname("photo", inmanagedobjectcontext: context) allow photo:photo = photo(entity:en, insertintomanagedobjectcontext:context)

osx core-data swift

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -