nsmanagedobjectcontext

Accessing deleted objects in iCloud notification

拥有回忆 提交于 2019-12-06 12:29:13
I have an app set up much like the iCloudCoreDataRecipes sample (ie, using Core Data in conjunction with iCloud). In the app delegate, I observe the NSPersistentStoreDidImportUbiquitousContentChangesNotification When a notification arrives, I call [context mergeChangesFromContextDidSaveNotification:note]; I have some additional processing I'd like to do when this notification is received but am having trouble using the objects identified by the NSManagedObjectID's present in the NSDeletedObjectsKey set. NSSet *deletedObjects = [info objectForKey:NSDeletedObjectsKey]; for (NSManagedObjectID

NSFetchedResultsController not firing delegate method after merging update from background thread

这一生的挚爱 提交于 2019-12-06 08:15:42
问题 I have an NSFetchedResultsController and a few operations that inserts and updates managed objects on separate threads via NSOperationQueue. The FRC looks like this, note that I have set the cache to nil: [NSFetchedResultsController deleteCacheWithName:nil]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:nil]; Each threaded operation has its

Core Data: should I be fetching objects from the parent context or does the child context have the same objects as the parent?

爷,独闯天下 提交于 2019-12-06 05:03:47
问题 I am slightly confused about parent/child contexts for ManagedObjectContext . When I setup a child context and set the parent context, does the child context contain all the objects of the parent context? I am using the stock Core Data methods that get created in the AppDelegate , but I changed the ConcurrencyQueue to main. In my method that is supposed to update the db: Create child context, set parent context Perform block on child context Fetch from parent context Create or update object

Configure NSFetchedResultsController in background when launching Core Data app

不打扰是莪最后的温柔 提交于 2019-12-06 04:48:18
I have setup a Core Data app with the usual boilerplate code, and the RootViewController initializes the FRC by calling this: - (NSFetchedResultsController *)fetchedResultsController { if (__fetchedResultsController != nil) { return __fetchedResultsController; } // configure the fetchRequest, sectionKey and cacheName __fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: sectionKey cacheName: cacheName]; return __fetchedResultsController; } All the sample code I've seen does this.

Core data Multi level parent - Child context

怎甘沉沦 提交于 2019-12-06 00:26:48
问题 In my app I have UITableViewController that shows event list. This controller uses ManagedObjectContext Say ParentContext . Now if any Event is selected, then a detailed View Controller is shown where users can edit the details of Event. So i have created a child context say, ChildContext with type "NSPrivateQueueConcurrencyType" ChildContext whose parent Context is "ParentContext". My code is: NSManagedObjectContext *childContext = [[NSManagedObjectContext alloc] initWithConcurrencyType

Does an NSManagedObject retain its NSManagedObjectContext?

旧街凉风 提交于 2019-12-05 16:58:23
NSManagedObject provides access to its NSManagedObjectContext , but does it retain it? According to "Passing Around a NSManagedObjectContext on iOS" by Marcus Zarra , "The NSManagedObject retains a reference to its NSManagedObjectContext internally and we can access it." How does Zarra know this and is he correct? I'm asking because I want to know if the NSManagedObjectContext will be dealloc 'ed in the tearDown method below. (I'm using CocoaPlant .) #import <SenTestingKit/SenTestingKit.h> #import <CocoaPlant/CocoaPlant.h> #import "AccountUser.h" @interface AccountUserTests : SenTestCase {

Passing a managedObjectContext through to a UITabBarController's views

白昼怎懂夜的黑 提交于 2019-12-05 13:39:06
I have an app which is based on the Utility template (where you flip over the view to see another). On the first view there is a login screen, then it flips over to reveal a UITabBar style interface. I'm having trouble working out how to pass the managedObjectContext from the App Delegate (where it is created) all the way through to each of the Tab Bar's views. App Delegate's managedObjectContext get passed to FrontLoginViewController which gets passed to BackViewTabBarViewController .. where next? The BackViewTabBarViewController nib has a UITabBarController with a UINavigationController for

Duplication of entity when change made by a child ManagedObjectContext is pushed (saved) to its parent

落爺英雄遲暮 提交于 2019-12-05 11:20:28
I expect (hope even) that this will be a stupid question, but after wrestling for many hours with this problem I need some insight. My iOS 5.1 app uses nested MOCs, having a PrivateQueueConcurrency child MOC, call it MOC-Child, whose parent is a MainQueueConcurrency MOC, call it MOC-Parent. MOC-Parent backs a table view that displays its entities. MOC-Child is used by a parser, which runs asynchronously on a non-main thread, to create new entities that correspond to XML entity-descriptions parsed from a URL connection, and then push the new entities to the MOC-Parent, via a save on the MOC

Core-Data: NSLog output Does Not Show “Fields”

一笑奈何 提交于 2019-12-05 10:49:42
I don't understand the output of NSLog for the array returned by a NSFetchRequest. I'm reading my database and placing the contents in an array, looping through the array and then outputting the contents with NSLog. I don't quite understand the output in the log file. Code below: -(void)createXMLFeed{ //Fetch details from the database. NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Tabrss" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; NSError *error; self.stories = [[managedObjectContext

Clearing a context in Core Data: reset vs deleting registered objects?

可紊 提交于 2019-12-05 09:54:32
I was looking for posts regarding to this, but I don't fully understand... What is the difference between: [context reset]; and: for (NSManagedObjectID *objId in objectIds) { [context deleteObject:[context objectWithID:objId]]; } Or are they equivalent? Thanks Using reset puts the managed object context back to the state it was in when you first created it-- before you had performed any fetches, created any new objects, etc. If you have any managed objects in memory that were fetched from this context, they're now unusable. Using reset does not affect the persistent store file . All instances