ios - How to change attribute type in xcdatamodel? -


i'm newbie assigned gigantic project. have found minor bug needs fixing don't know how.

ok here is. issuenumber attribute in xcode's core data model set integer 64. need change string, bug fixed, when change attribute type integer 64 string, app crashes gigantic output starts this:

coredata: error: -addpersistentstorewithtype:sqlite configuration:(null) url:file:///users/apple/library/developer/coresimulator/devices/67d17d00-2af8-4bc4-abb7-091c95d02f35/data/containers/data/application/b94b1310-4a63-4f91-ae7b-5f625697b3e2/library/imagdocument.sqlite options:{ nsinfermappingmodelautomaticallyoption = 1; nsmigratepersistentstoresautomaticallyoption = 1; nssqlitepragmasoption = { synchronous = off; }; } ... returned error error domain=nscocoaerrordomain code=134130 "the operation couldn’t completed. (cocoa error 134130.)" userinfo=0x7f405ef0 {url=file:///users/apple/library/developer/coresimulator/devices/67d17d00-2af8-4bc4-abb7-091c95d02f35/data/containers/data/application/b94b1310-4a63-4f91-ae7b-5f625697b3e2/library/imagdocument.sqlite, metadata={ nspersistenceframeworkversion = 519; nsstoremodelversionhashes = {

and goes , goes... here do: change type in data model integer 64 string:

ok doing wrong? there must i'm missing, app crashes every time change attribute type.

share|improve question
up vote 1 down vote accepted

this complex problem. can't change datatype of attribute. error see means core data not able migrate data new version.

1) create new model version instead , set new data type there. see https://developer.apple.com/library/ios/recipes/xcode_help-core_data_modeling_tool/articles/creating_new_version.html

2) set new model version used. https://developer.apple.com/library/ios/recipes/xcode_help-core_data_modeling_tool/articles/setting_current_version.html

3) have add persistent store options nsmigratepersistentstoresautomaticallyoption , nsinfermappingmodelautomaticallyoption.

nsdictionary *options = @{nsmigratepersistentstoresautomaticallyoption: [nsnumber numberwithbool:yes],                           nsinfermappingmodelautomaticallyoption: [nsnumber numberwithbool:yes]                           }; 
share|improve answer
    
thank answer... figured it's complex, i'm going try answer... bunch :) – miljan jun 11 '15 @ 8:14
    
now works bunch :) – miljan jun 11 '15 @ 12:52

this right method:

- (nsdictionary *)persistentstoreoptions {     return @{nsinfermappingmodelautomaticallyoption: @yes,              nsmigratepersistentstoresautomaticallyoption: @yes,              nssqlitepragmasoption: @{@"synchronous": @"off"}}; } 
share|improve answer

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments