nsmanagedobjectcontext

NSManagedObjectContextObjectsDidChangeNotification not always called instantly

a 夏天 提交于 2019-12-12 08:05:07
问题 I have an Mac Application using a NSPersistentDocument. I want to get notified when Objects are deleted to save this information using Core Data. So I'm listening for NSManagedObjectContextObjectsDidChangeNotification. Often it is called instantly when objects are deleted, but sometimes it is only called after the persistent document is saved with all deleted objects not being notified before. Because I want to let the user directly export all existing objects (and not the deleted anymore)

Process JSON data coming from server and add/update the objects in CoreData

孤街浪徒 提交于 2019-12-12 05:12:41
问题 I am working on app which uses coreData , I have two entities called folder and notes . So their is one to many relationship between folders-> notes. i.e 1 folder = many notes. I have used fetch results controller for folders, and it is displayed on the UITableView, when user clicks a folder, he goes to notes table, which displays notes inside the particular folder. User can add and delete folders/Notes. Everything works fine. Everything here is offline. Now I am trying to synchronise this

NSFetchedResultsController seems to be inserting empty objects into array?

泄露秘密 提交于 2019-12-12 03:49:22
问题 I'm not sure what's going wrong. I have one Entity in my data model, called Quote, and around 3,000 of them stored in a .sqlite. I'm just trying to get one of the attributes of those entities into the cells of a UITableView , by way of an NSFetchedResultsController . The error I'm getting is on this line of code: NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: [self managedObjectContext]

Core Data - Re-saving Object in didSave

…衆ロ難τιáo~ 提交于 2019-12-12 02:06:31
问题 I have to check for certain properties after saving the object to the database (I need to make sure first that it's saved on disk). So, I thought that the didSave method of NSManagedObject is the best place to do so. However, after checking for these properties and changing some of them, I want to re-save the object. So, I call the managed object context to save the object one more time . (I made heavy testing to make sure I won't get into an infinite loop). Now, the problem is the managed

Core Data Concurrency - Collection was mutated while being enumerated

让人想犯罪 __ 提交于 2019-12-12 01:35:21
问题 I'm adding some objects called Transaction s in my Core Data application. Those transactions are linked to an account. I'd like to update the account amount when all the transactions are saved. Sometimes there is a concurrency exception "Collection was mutated while being enumerated" at NSArray *matches = [managedObjectContext executeFetchRequest:request error:&error]; line in accountManagedObjectWithId method. //TransactionsManager - (BOOL)addRepeatTransaction:(Transaction *)transaction{

Saving the managedObjectContext for a specific object

走远了吗. 提交于 2019-12-12 01:29:42
问题 I'm trying to learn Core Data, and am having trouble updating the MOC after adding new objects to an existing object. I can create the original object, a training day, and I can add exercise objects to that training day, but I can't figure out how to save the context so that later in my application I can find all exercises in a training day. Any ideas?? Here is my code: // Data from JSON NSArray *trainingDayData = responseData[@"training_days"]; for (NSDictionary *aTrainingDay in

Save managedObjectContext partly

♀尐吖头ヾ 提交于 2019-12-12 01:22:57
问题 I have 3 transaction already in NSManagedObjectContext : A , B , C . They were performed / added to context in the same order. How can I save only the first A transaction, but keep unsaved B , C on context. insert A , insert B , insert C , commit A , .. Unfortunately NSManagedObjectContext can not do commit A , but save all the transactions. 回答1: Maybe I missing something. Your goal is to save a specific object, say A , only and only if A 's data has been committed to the server. Am I wrong?

NSManagedObjectContextDidSaveNotification not triggered in iOS 7

余生颓废 提交于 2019-12-11 21:12:04
问题 I have a situation where I make some changes to the properties of a NSManagedObject in main thread. It belongs to the main ManagedObjectContext of the app. My app does has threading enabled which downloads data, each thread has it's own ManagedObjectContext created from the most recent state of a single PersistentStore throughout the application. I am implementing NSManagedObjectContextDidSaveNotification so that any changes in the MOC is merged back to the main thread's MOC too. Below is the

CoreDataTableView Not Updating When Saving From Child ManagedObjectContext and Parent ManagedObjectContext

孤者浪人 提交于 2019-12-11 19:22:07
问题 I'm trying to populate CoreData from a JSON file with thousands of entries. What I'm trying to do is create a new NSManagedObjectContext with the parent property set to my main NSManagedObjectContext. Every so often I save on my child context and if successful then save on my main context. If that's also successful I try to reload my tableview. My CoreDataTableView is setup with an NSFetchedResultController and taken directly from Apple's documentation. However, the table view isn't refreshed

Hang in mergeChangesFromContextDidSaveNotification (and merge conflicts)

一个人想着一个人 提交于 2019-12-11 18:06:53
问题 In summary: My app is hanging when I call [myMOC mergeChangesFromContextDidSaveNotification:notification] in a multithreaded scenario. The detailed situation is this: My app downloads a whole bunch of data from a server and stores it in Core Data on first launch. It comes in several parts. Parsing the whole thing takes several seconds, and most of that time is spent on two of the chunks. So in order to speed it up, I've parallelized those two chunks. This is what it looks like: NSArray *arr =