nsmanagedobjectcontext

Changes saved from one NSManagedObjectContext doesn't reflect on main NSManagedObjectContext

三世轮回 提交于 2019-12-20 11:59:08
问题 I have a main NSManagedObjectContext that's created in the appDelegate . Now, I'm using another NSManagedObjectContext for editing/adding new objects without affecting the main NSManagedObjectContext , until I save them. When I save the second NSManagedObjectContext , the changes are not reflected in the main NSManagedObjectContext , yet if I open the .sqlite database from simulator, the changes have been saved correctly into the .sqlite database. It doesn't matter if I fetch the data again,

iPhone iOS how to merge Core Data NSManagedObjectContext?

假如想象 提交于 2019-12-20 10:56:08
问题 I'm trying to download some JSON objects in the background and am doing quite a bit of multi threading. Once the operation completes, I noticed that this assertion fails: NSAssert([user.managedObjectContext isEqual:[AppUser managedObjectContext]],@"Different contexts"); How can I merge changes into the main context defined by [AppUser managedObjectContext] ? 回答1: I really suggest you to read the following link on importing-and-displaying-large-data-sets-in-core-data by Marcus Zarra . When you

Core Data viewContext not receiving updates from newBackgroundContext() with NSFetchedResultsController

安稳与你 提交于 2019-12-20 08:35:53
问题 In my application, I have a NSFetchedResultsController to load Core Data objects in a UITableView. The fetch request associated with this FRC uses the new viewContext property available for the NSPersistentContainer (iOS10). When I select a cell, I pass the Core Data object to a new ViewController. This new VC still uses the viewContext. From this ViewController, I can update the Core Data object from ViewControllers presented modally. To do so, I use newBackgroundContext() for the modal

Context does not save the changes with error 1550

倾然丶 夕夏残阳落幕 提交于 2019-12-20 02:13:51
问题 I'm trying to update an entity and save the changes. I'm getting always the following error: The operation couldn’t be completed. (Cocoa error 1550.) Method: - (BOOL) updateEvent:(EventDTO*)eventDTO{ BOOL saved = YES; [self getDataCoreContext]; if (context) { NSError *error; Event *myEvent = (Event *)[context existingObjectWithID:eventDTO.entitysID error:&error]; myEvent.name = eventDTO.name; myEvent.descrptn = eventDTO.description; myEvent.date = eventDTO.date; myEvent.locLatitude =

Store But Don't Save NSManagedObject to CoreData?

只愿长相守 提交于 2019-12-19 18:29:18
问题 I have a short setup process in my app and I create an NSManagedObject to store name and other details of an individual, however during this setup I don't want to save the object until the user presses 'Done' right at the end of the setup (just incase they cancel the setup for whatever reason). So is it possible to keep hold the object holding my info for a short time until the end of the setup process without actually saving it into CoreData? 回答1: When you are dealing with CoreData, all add

NSMergeConflict for NSManagedObject with single ManagedObjectContext

爱⌒轻易说出口 提交于 2019-12-19 11:58:31
问题 I am working with coreData, I have one to many relationship between folders and files. I am using only one MOC through out my application .I am just passing it to different viewControllers , performing operations like add, edit, delete and then saving. My rootViewController uses NSfetchResultsController, I create folders using it, save and display on my table. saving I do it this way NSError *error; if (![self.managedObjectContext save:&error]) { // Replace this implementation with code to

Multi Context CoreData with Threads

南笙酒味 提交于 2019-12-19 11:27:44
问题 UPDATE : I suppose the issue is that the parent context is not updated when the child context is saved. Still, need help. I have tried many examples of Multi-context (Parent-Child) Core Data. Previously my app was using the traditional way of storing data, i.e. I used an OperationQueue where I fetch the data from the server and save to the DB using a MOC and on saving fire a notification to the mainMOC to mergeChanges : NSManagedObjectContextDidSaveNotification. Without disturbing the flow of

Best approach to update managed objects from async web services responses?

吃可爱长大的小学妹 提交于 2019-12-19 11:18:33
问题 I have an NSManagedObjectContext associated to main thread ( mainContext ), where I fetch all the NSManagedObject I show throughout the app. Users don't edit these objects, but I get updates from web services. I periodically perform asynchronous calls to such services, and they "tell" me which of my managed objects have to be deleted (if any), which of them have to be updated with new information (if any), and if I need to insert new objects. So, I need to firstly get the responses of all the

Does NSFetchedResultsController Observe All Changes to Persistent Store?

╄→尐↘猪︶ㄣ 提交于 2019-12-19 06:16:14
问题 My program does work like link below: Update results of NSFetchedResultsController without a new fetch show result of NSFetchedResultsController to UITableView get new object from web service and store it to core data (in same view controller, with RestKit) update table view with notification of NSFetchedResultsController delegate The implementation of NSFetchedResultsControllerDelegate is copied from Apple's Core Data project and my predicated is: [NSPredicate predicateWithFormat:@"isMyTest

Passing managedObjectContext - is this efficient?

本秂侑毒 提交于 2019-12-19 04:49:06
问题 I have an app I am working on. There is a navigation controller, and my appDelegate is passing its managedObjectContext to the nav controllers root controller like so: RootViewController *rootViewController = (RootViewController *)[navigationController topViewController]; rootViewController.managedObjectContext = self.managedObjectContext; (Bonus question - I've read the above is the preferred way to pass the context, as opposed to some examples I see where the view controller grabs the