nsmanagedobjectcontext

trying to save NSManagedObjectContext not working

跟風遠走 提交于 2021-02-18 22:09:05
问题 I have been trying to figure out this problem for 2 days now. I keep getting an error when I try to save. //self.data is NSManagedObject. kAppDelegate.moc is the managed object context. self.data = [NSEntityDescription insertNewObjectForEntityForName:@"Data" inManagedObjectContext:kAppDelegate.moc]; [self.data setValue:[NSNumber numberWithBool:NO] forKey:@"isit"]; [self.data setValue:@"" forKey:@"name"]; NSError *error; if(![self.data.managedObjectContext save:&error]) { NSLog(@"Save did not

Is it possible to return NSManagedObjects as read-only in Core Data?

扶醉桌前 提交于 2021-01-28 01:50:41
问题 I'm using Core Data for caching of server data in a module that I'm writing and would like to be able to enforce that other parts of the application don't modify that data. Is is possible to mark either my instances of NSManagedObject, or the NSManagedObjectContext used to fetch them, as read-only? Since the context is accessible directly from the object, consumers are free to modify the object and call [obj.managedObjectContext save:&errror] . I've seen plenty of references to creating a

CoreData merge conflict shows managed object version change not data

时光怂恿深爱的人放手 提交于 2020-12-26 07:19:17
问题 I am have an entity in core data and I try to update it from two different context. I am storing managedObjectID of my managed object which I need to update as it is thread safe. Before updating my object I refresh the object to avoid merge conflict. Here is my code: context1.performBlock { let myObject = context1.objectWithID(managedObjectId) context1.refreshObject(myObject, mergeChanges: true) myObject.property1 = newValue } Notice that I haven't saved the context here, as I want to commit

CoreData ManagedObjectContext Recursive Save Error

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 10:40:06
问题 Some users of mine are encountering a CoreData error when performing a save. I haven't been able to find any information online about this error or how to symbolicate the stack trace. The error message is attempt to recursively call -save: on the context aborted, stack trace , with the full error message below. Doe anyone have any hints or ideas on how to figure out what is going wrong? Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save:

CoreData ManagedObjectContext Recursive Save Error

别来无恙 提交于 2020-01-22 10:39:08
问题 Some users of mine are encountering a CoreData error when performing a save. I haven't been able to find any information online about this error or how to symbolicate the stack trace. The error message is attempt to recursively call -save: on the context aborted, stack trace , with the full error message below. Doe anyone have any hints or ideas on how to figure out what is going wrong? Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save:

NSManagedObjectContext's propagatesDeletesAtEndOfEvent set to false causes error on save

荒凉一梦 提交于 2020-01-14 14:13:50
问题 I have a pair of Core Data Entities of One-to-Many relationship. Department <-(optional) (delete rule: Cascade) (optional)->> Item Item <-(optional) (delete rule: Nullify) (optional)->> Department Item is a tree node-like entity, which also has a relationship to itself. The tree can grow quite large (more than 10 thousands nodes in a root branch). There are a parent background NSManagedObjectContext and a main-queue one as the child. In the hope of making deletion of Items feel faster, I set