core data - Odd behaviour of insertNewObjectForEntityForName leading to NSInternalInconsistencyException -



core data - Odd behaviour of insertNewObjectForEntityForName leading to NSInternalInconsistencyException -

i have rather odd case of getting core info error whilst experimenting swift. not sure whether comes swift (beta error?) or whether me. however, here setup test cases (in vtmodeltests.swift).

var bundle = nsbundle(forclass: vtmodeltests.self) var url = bundle.urlforresource("vtdocument", withextension:"momd") applemodel = nsmanagedobjectmodel(contentsofurl: url) assert (applemodel != nil) var coord = nspersistentstorecoordinator(managedobjectmodel: applemodel); var store = coord.addpersistentstorewithtype(nsinmemorystoretype,configuration:nil,url:nil,options:nil,error:nil); assert (store != nil) ctx = nsmanagedobjectcontext(); ctx!.persistentstorecoordinator=coord ctx!.retainsregisteredobjects=true; var drwname = "drawing" var descs = ctx!.persistentstorecoordinator.managedobjectmodel.entitiesbyname e : anyobject in descs.allkeys{ assert (descs.objectforkey(e).name == e string ) if (e string == drwname) { nslog("yeah") } } model = nsentitydescription.insertnewobjectforentityforname(drwname,inmanagedobjectcontext: ctx) drawing

my error message looks this:

2014-06-22 22:12:25.584 xctest[63792:303] yeah <unknown>:0: error: -[_ttc12vtmodeltests12basetypetest testtreestructure] : failed: caught "nsinternalinconsistencyexception", "+entityforname: not locate entity named 'drawing' in model."

in short, can "prove" entity name there (the 'yeah' in log), core info showing issue name not in model. previous versions of loop printed out entities , looked good. don't have sec versions, , new changed name ('model' called 'drawing') correctly shown in model info when entities printed. compiled model in resulting bundle.

can explain? or have wait next beta release of xcode 6? else did overlook? many in advance!

i can confirm issue. not reply way around utilize split insertnewobjectforentityforname into:

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

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 -