nsmanagedobject

Core-Data willSave: method

倾然丶 夕夏残阳落幕 提交于 2019-11-26 19:30:03
问题 I have an attribute modificationDate in my Entity A. I want to set its value whenever NSManagedObject is saved. However, if i try to do that in NSManagedObject willSave: method, i get an error: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to process pending changes before save. The context is still dirty after 100 attempts. Typically this recursive dirtying is caused by a bad validation method, -willSave, or notification handler.' *** So, i

Is there a way to instantiate a NSManagedObject without inserting it?

℡╲_俬逩灬. 提交于 2019-11-26 18:52:06
问题 I have a user interface to insert a Transaction. once the user clicks on a plus he gets the screen and i want to instantiate my Core Data NSManagedObject entity let the user work on it. Then when the user clicks on the Save button i will call the save function. so down to code: transaction = (Transaction *)[NSEntityDescription insertNewObjectForEntityForName:@"Transaction" inManagedObjectContext:self.managedObjectContext]; //even if i dont call save: its going to show up on my table [self

Swift + CoreData: Cannot Automatically Set Optional Attribute On Generated NSManagedObject Subclass

主宰稳场 提交于 2019-11-26 18:07:20
问题 I have a coredata entity named Record and has a property dateUpdated. I noticed that the generated NSManagedObject subclass has no optional mark (?) CoreData Editor: Generated Subclass: Expected: UPDATED: It's tedious in my part, because each time I want to regenerate the subclasses, it means I also need to update all optional values manually. Having a non-optional (without '?') in subclass lead me to check evalue before assigning, like example below: // sample value: // serverDateFormatter =

Setting up a parent-child relationship in Core Data

时光总嘲笑我的痴心妄想 提交于 2019-11-26 16:29:46
问题 I'm trying to set up a relationship in Core Data. I have a list of Trees, and each Tree will have a list of Fruits. So I have a Tree entity and a Fruit entity. In code, I will want to list the Trees, in a table view for example. When you click on a Tree, it should then display a list of fruits that growing on that Tree. How do I set up this relationship? Do I need to give the Fruit an attribute called tree? And how do I set the relationship in code, for example when I create a Fruit how do I

How do I copy or move an NSManagedObject from one context to another?

删除回忆录丶 提交于 2019-11-26 15:05:48
问题 I have what I assume is a fairly standard setup, with one scratchpad MOC which is never saved (containing a bunch of objects downloaded from the web) and another permanent MOC which persists objects. When the user selects an object from scratchMOC to add to her library, I want to either 1) remove the object from scratchMOC and insert into permanentMOC, or 2) copy the object into permanentMOC. The Core Data FAQ says I can copy an object like this: NSManagedObjectID *objectID = [managedObject

NSPrivateQueueConcurrencyType Not saving properly

安稳与你 提交于 2019-11-26 14:42:27
问题 The following method gets called in order to populate my Core-Data after AFNetworking fetches information from my app server. The information seems to be perfectly working as when the table is updated I can see the new information being updated in the UITableView . Now the problem that I have is that even tho I can see the information ( after it has been fetches from the server, stored into Core-data and refetches to display in my UITableView ) If I then go and close my app and re open it,

How can I duplicate, or copy a Core Data Managed Object?

。_饼干妹妹 提交于 2019-11-26 12:20:01
问题 I have a managed object (\"A\") that contains various attributes and types of relationships, and its relationships also have their own attributes & relationships. What I would like to do is to \"copy\" or \"duplicate\" the entire object graph rooted at object \"A\", and thus creating a new object \"B\" that is very similar to \"A\". To be more specific, none of the relationships contained by \"B\" (or its children) should point to objects related to \"A\". There should be an entirely new

CoreData: warning: Unable to load class named

南楼画角 提交于 2019-11-26 11:43:38
I am duplicating an existing Objective-C TV Show app to a new Swift version using Xcode 6.1 and am having some issues with CoreData. I have created a model of 4 entities, created their NSManagedObject subclass (in Swift), and all files have the proper app targets set (for 'Compile Sources'). I am still getting this error whenever I try to insert a new entity: CoreData: warning: Unable to load class named 'Shows' for entity 'Shows'. Class not found, using default NSManagedObject instead. A few comments: When saving to Core Data, I use the parent-child context way to allow background threading.

How can I tell whether an `NSManagedObject` has been deleted?

青春壹個敷衍的年華 提交于 2019-11-26 08:47:35
问题 I have an NSManagedObject that has been deleted, and the context containing that managed object has been saved. I understand that isDeleted returns YES if Core Data will ask the persistent store to delete the object during the next save operation. However, since the save has already happened, isDeleted returns NO . What is a good way to tell whether an NSManagedObject has been deleted after its containing context has been saved? (In case you\'re wondering why the object referring to the

Changing a managed object property doesn't trigger NSFetchedResultsController to update the table view

拜拜、爱过 提交于 2019-11-26 07:27:38
问题 I have a fetchedResultsController with a predicate, where \"isOpen == YES\" When calling for closeCurrentClockSet , I set that property to NO . Therefore, it should no longer appear on my tableView. For Some Reason, this is not happening. Can someone help me figure this out please? -(void)closeCurrentClockSet { NSPredicate * predicate = [NSPredicate predicateWithFormat:@\"isOpen == YES\"]; NSArray *fetchedObjects = [self fetchRequestForEntity:@\"ClockSet\" withPredicate:predicate