core-data

Overriding setters with arc and dynamic properties

喜欢而已 提交于 2020-01-14 14:56:09
问题 I need to do some additional stuff in a setter method. But I get an infinite loop when doing so: I've got a core data object @interface Transaction : NSManagedObject @property (nonatomic, retain) NSDate * date; @end @implementation Transaction @dynamic date; -(void)setDate:(NSDate *)date { self.date = date; //additional stuff omitted } So, in that case I get an infinite loop. Okay so I searched on the net and modified my code in the following way and for every version I get compiler errors

Overriding setters with arc and dynamic properties

和自甴很熟 提交于 2020-01-14 14:56:05
问题 I need to do some additional stuff in a setter method. But I get an infinite loop when doing so: I've got a core data object @interface Transaction : NSManagedObject @property (nonatomic, retain) NSDate * date; @end @implementation Transaction @dynamic date; -(void)setDate:(NSDate *)date { self.date = date; //additional stuff omitted } So, in that case I get an infinite loop. Okay so I searched on the net and modified my code in the following way and for every version I get compiler errors

NSManagedObjectContext's propagatesDeletesAtEndOfEvent set to false causes error on save

荒凉一梦 提交于 2020-01-14 14:13:50
问题 I have a pair of Core Data Entities of One-to-Many relationship. Department <-(optional) (delete rule: Cascade) (optional)->> Item Item <-(optional) (delete rule: Nullify) (optional)->> Department Item is a tree node-like entity, which also has a relationship to itself. The tree can grow quite large (more than 10 thousands nodes in a root branch). There are a parent background NSManagedObjectContext and a main-queue one as the child. In the hope of making deletion of Items feel faster, I set

Core Data deleteObject: sets attributes to nil

允我心安 提交于 2020-01-14 13:32:07
问题 I am implementing an undo/redo mechanism in my app. This works fine for lots of cases. However, I can't undo past deleteObject:. the object is correctly saved in the undo queue, and I get it back and reinsterted into the Core Data stack just fine when calling undo. The problem is that all it's attributes are getting set to nil when I delete it. I have an entity "Canvas" with a to-many relationship called "graphics" to a "Graphic" entity, which has its inverse set to "canvas". Deleting a

NSFetchRequest not catching objects that have a changed property

淺唱寂寞╮ 提交于 2020-01-14 13:28:11
问题 I have run into a weird problem with CoreData on MacOsX 10.6 using an SQL store. I have an NSManagedObject subclass called Family with attribute name and a relationship personList connected to another NSManagedObject subclass called Person with attribute firstname and inverse relationship family . A Person has only one family , and a family can have several Person s. Say I have a Family object family pointing to the family 'Doe' with 2 Person (John and Jane) connected to it and I do the

Unable to instantiate NSFetchedResultController with generic type AnyObject in Swift 3

时光总嘲笑我的痴心妄想 提交于 2020-01-14 13:05:53
问题 I'm experimenting with CoreData in Swift 3 and have come up against a very bizarre circular compiler error in Xcode 8 beta. NSFetchedResultsController needs a generic type parameter and AnyObject has worked fine up until now. The compiler throws the error: Type 'AnyObject' does not conform to protocol 'NSFetchRequestObject' To make me extra confused, if you delete the type parameter, XCode then says: Reference to generic type NSFetchedResultsController requires argument in `<...>` and

Core data insert multiple objects

梦想与她 提交于 2020-01-14 09:49:05
问题 Is that the right way to save multiple objects with relationships? Or is there a way to improve the code and save the context just one time? Thanks!! for (NSDictionary *entries in dataArray){ module = [NSEntityDescription insertNewObjectForEntityForName:@"Modules" inManagedObjectContext:context]; module.m_id=[entries objectForKey:@"id"]; module.m_name = [entries objectForKey:@"name"]; module.m_timestamp = [NSDate date]; //This line links the product by adding an entry to the NSSet of list for

Core data insert multiple objects

亡梦爱人 提交于 2020-01-14 09:48:59
问题 Is that the right way to save multiple objects with relationships? Or is there a way to improve the code and save the context just one time? Thanks!! for (NSDictionary *entries in dataArray){ module = [NSEntityDescription insertNewObjectForEntityForName:@"Modules" inManagedObjectContext:context]; module.m_id=[entries objectForKey:@"id"]; module.m_name = [entries objectForKey:@"name"]; module.m_timestamp = [NSDate date]; //This line links the product by adding an entry to the NSSet of list for

“Cannot load NSManagedObjectModel. nil is an illegal URL parameter”

放肆的年华 提交于 2020-01-14 07:21:23
问题 I want to get the managed object context from AppDelegate, but the app crashed after I put the two lines of code into the method even I did nothing else, and there was a message in debug area: "CoreData: Cannot load NSManagedObjectModel. nil is an illegal URL parameter..." The code added in my method: AppDelegate *delegate = [UIApplication sharedApplication].delegate; NSManagedObjectContext *managedObjectContext = delegate.managedObjectContext; -managedObjectModel method in AppDelegate: -

“Cannot load NSManagedObjectModel. nil is an illegal URL parameter”

做~自己de王妃 提交于 2020-01-14 07:21:11
问题 I want to get the managed object context from AppDelegate, but the app crashed after I put the two lines of code into the method even I did nothing else, and there was a message in debug area: "CoreData: Cannot load NSManagedObjectModel. nil is an illegal URL parameter..." The code added in my method: AppDelegate *delegate = [UIApplication sharedApplication].delegate; NSManagedObjectContext *managedObjectContext = delegate.managedObjectContext; -managedObjectModel method in AppDelegate: -