ios - NSBatchUpdateRequest throwing NSInternalInconsistencyException -
i keep getting following error when trying perform nsbatchupdaterequest.
*** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'unknown command type <nsbatchupdaterequest : entity = person, properties = { "(<nsattributedescription: 0x6000000ff980>), name title, isoptional 1, istransient 0, entity (null), renamingidentifier title, validation predicates (\n), warnings (\n), versionhashmodifier (null)\n userinfo {\n}, attributetype 700 , attributevalueclassname nsstring, defaultvalue (null)" = "\"sometitle\""; }, subentities = 1'
the error log shows "entity (null)", when correctly specified in constructor.
i running test environment , wonder if nsbatchupdaterequest supports nspersistentstorecoordinator nsinmemorystoretype. cant find in docs not supported.
below code using. entity , property parameters correct , shouldn't causing issue.
-(bool) updatepersonnamesfrom:(nsstring*)oldname newname:(nsstring*)newname { nsbatchupdaterequest* updaterequest = [[nsbatchupdaterequest alloc] initwithentityname:@"person"]; // person model exists nslog(@"entity name: %@", updaterequest.entityname); // logs correct entity name // adding or removing predicate has no effect // [updaterequest setpredicate:[nspredicate predicatewithformat:@"name = %@", oldname]; updaterequest.propertiestoupdate = @{@"name" : newname}; // name field exists on person nserror* error = nil; [m_context executerequest:updaterequest error:&error]; // tried // [m_context.persistentstorecoordinator executerequest:updaterequest withcontext:self error:&error]; return error != nil; }
if has ideas love hear it.
from guide:
important: batch updates available when using sqlite persistent store.
sorry. maybe it'll work in ios 11. ¯\_(ツ)_/¯
Comments
Post a Comment