nsmanagedobjectcontext

Full Example Of Implementing Notifications For Core Data NSManagedObject

你离开我真会死。 提交于 2020-01-05 10:29:52
问题 Could somebody point me in the correct direction for a full implementation example of NSManagedObjectContextObjectsDidChangeNotification NSManagedObjectContextDidSaveNotification and NSManagedObjectContextWillSaveNotification I have read the references to it here: http://developer.apple.com/library/ios/#documentation/cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html but I don't see a full example code of exactly where I should implement it so

Full Example Of Implementing Notifications For Core Data NSManagedObject

巧了我就是萌 提交于 2020-01-05 10:28:09
问题 Could somebody point me in the correct direction for a full implementation example of NSManagedObjectContextObjectsDidChangeNotification NSManagedObjectContextDidSaveNotification and NSManagedObjectContextWillSaveNotification I have read the references to it here: http://developer.apple.com/library/ios/#documentation/cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html but I don't see a full example code of exactly where I should implement it so

Observing changes in the properties of an NSManagedObject: how to avoid looping?

微笑、不失礼 提交于 2020-01-05 10:14:49
问题 In my application, I observe the properties of a managed object. A change may lead to adjustments in some of its other properties, so the managed object itself receives a message of a changed property. These changes happen through bindings that are set up in the Interface Builder. I have the following method in the implementation of the managed object: -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (

Observing changes in the properties of an NSManagedObject: how to avoid looping?

夙愿已清 提交于 2020-01-05 10:14:07
问题 In my application, I observe the properties of a managed object. A change may lead to adjustments in some of its other properties, so the managed object itself receives a message of a changed property. These changes happen through bindings that are set up in the Interface Builder. I have the following method in the implementation of the managed object: -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (

iOS: Swift: Core Data: Error: +entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name

安稳与你 提交于 2020-01-04 02:41:07
问题 I used Core Data for a table view with Swift Language. It can launch successfully, but after clicking Done button in AddView, there is an error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'OneItemCD'' I don't know why. Could anybody help me figure it out? Thanks very much! Here is the code. There is an add bar button item. Clicking this button transfer to

Why entries are not deleted until app is restarted or I execute my NSBatchDeleteRequest twice?

风流意气都作罢 提交于 2020-01-03 02:19:36
问题 I'm reading Delete/Reset all entries in Core Data?. If I follow the steps below, I get an unexpected result: Call the code below Then query an entity in the simulator, I will get an entity back!!! If I call clearCoreDataStore again (or do a restart), only then the value won't be retrieved from core-data What am I missing? func clearCoreDataStore() { let entities = dataManager.persistentContainer.managedObjectModel.entities for entity in entities { let fetchRequest = NSFetchRequest

Can Managed Object Contexts in different threads (main/private queues) handle the same objects?

倾然丶 夕夏残阳落幕 提交于 2020-01-03 01:51:24
问题 I have an NSManagedObjectContext in the main queue (the default context provided in AppDelegate ), and I create another NSManagedObjectContext in a private queue to request data updates to web services. I use the main context to fetch all the objects to be shown and managed throughout the app, and I use the private context to insert the new objects I receive from services to avoid blocking the UI and to also avoid "interfering" with the objects in the main context in case the user and/or the

Accessing deleted objects in iCloud notification

大兔子大兔子 提交于 2020-01-02 10:32:57
问题 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

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

霸气de小男生 提交于 2020-01-02 04:31:08
问题 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

performBlockAndWait On Child Context with Private Queue Deadlocks Parent on iOS 7

一笑奈何 提交于 2020-01-02 02:55:14
问题 I have two NSManagedObjectContext s named importContext and childContext . childContext is the child of importContext and both of them are NSPrivateQueueConcurrencyType . To keep things off the main thread, I'm doing a bunch of work on the importContext 's queue. This work involves lots of fetches and saves, so it's convenient to wrap the whole thing inside a performBlockAndWait: of the importContext (it does need to by a synchronous operation because the code I have after the