nsmanagedobject

Saving Single CoreData Entity (Not the Whole Context) While Keeping NSFetchedResultController Functionality

邮差的信 提交于 2019-12-03 12:38:55
Phew, sorry for the long title. I have a single Managed Object Context where I am storing songs derived from two different locations. I get some of the songs from the persistent storage on the phone (using Core Data), and I pull some of the songs from an online database. Both of the songs are of the same MananagedObject subclass. I would like both of these songs to be in a single context because I would like them both to show up on a table view connected with an NSFetchedResultsController. The problem occurs when I would like to save one of the songs. I don't want to save all of the songs that

Delete an object in core data

拥有回忆 提交于 2019-12-03 12:32:28
问题 I have an entity in my core data model like this: @interface Selection : NSManagedObject @property (nonatomic, retain) NSString * book_id; @property (nonatomic, retain) NSString * contenu; @property (nonatomic, retain) NSNumber * page_id; @property (nonatomic, retain) NSNumber * nbrOfOccurences; @property (nonatomic, retain) NSString * next; @property (nonatomic, retain) NSString * previous; I have created many Selection s and saved them in Core Data and now I would like to delete some

NSManagedObject and KVO vs Documentation

て烟熏妆下的殇ゞ 提交于 2019-12-03 11:07:00
问题 I have a custom NSManagedObject subclass, say, Person . I also have a UIView registered with -addObserver:forKeyPath:options:context: to observe various properties of a Person , some of which are persistent like "name" and others are just dumb KVO-compliant accessors unrelated to Core Data, like "drinking". @interface Person : NSManagedObject { BOOL drinking; } @property (nonatomic, retain) NSString* name; @property (nonatomic, readonly) BOOL drinking; @end @implementation Person @dynamic

Core Data - Iterating through the attributes of a NSManagedObject

青春壹個敷衍的年華 提交于 2019-12-03 10:27:58
I am a noob at core data, so here goes. I have a core data object, for example student. The student has mane attributes, like name, age, dob, address, and so on. Now I need to display all these attributes into a table view. Is there any easy way to iterate through the object student? Or do I have to convert the data into some type of dictionary? If I need to convert it to a dictionary is there any support for it? Or do I have to write the function my self. Many thanks for your help, Stephen Here's a very simple way to iterate over an NSManagedObject: NSEntityDescription *entity =

How can I set a Custom attribute of an NSManagedObject which is calculated from other attributes?

谁说胖子不能爱 提交于 2019-12-03 09:10:49
I am using core data framework to manage objects. I have an entity which has several attributes of decimal types. Among them is an attribute which is mathematically calculated from other attributes. Example: @interface Marks : NSManagedObject { } @property (nonatomic, retain) NSDecimalNumber * answerGradeA; @property (nonatomic, retain) NSDecimalNumber * answerGradeB; @property (nonatomic, retain) NSDecimalNumber * answerGradeC; @property (nonatomic, retain) NSDecimalNumber * total; Here I want attribute total = 3xanswerGradeA + 2xanswerGradeB + 1xanswerGradeC . If it is possible to do like

MagicalRecord relationship mapping duplicates objects despite primary keys

北城余情 提交于 2019-12-03 08:09:38
I'm in need of some assistance for an issue I am experiencing with MagicalRecord data importing. I was under the impression that MagicalRecord was able to handle relationship mapping without duplicating objects by looking at the primary keys ( relatedByAttribute ). Here's a simple JSON: [ { parentId: "<unique id>", parentName : "<name>", children : [ { childId: "<unique id>", childName: "<name>" }, { childId: "<unique id>", childName: "<name>" } ] }, { <another parent with children> } ] I've got an NSManagedObject Parent which has a to-many relationship with a Child NSManagedObject. The

“[something copyWithZone:]: unrecognized selector sent to instance” when using Bindings / Core Data

孤人 提交于 2019-12-03 06:36:48
问题 (self asking and self-answering because I spent hours on the web looking for this, and most of the resources all say "I solved it in the end" without giving an explanation) I had a very simple Core Data + Bindings application: An NSArrayController pulling items out of Core Data An NSTableView rendering them Another NSTableView that when you click on a row in the first table, displays the details of that item Item 3 above was causing application crash, with the error: [(my NSManagedObject)

Storing NSManagedObject in a dictionary (NSDictionary)

喜夏-厌秋 提交于 2019-12-03 04:22:50
问题 I have a custom class, which is a subclass of NSManagedObject . I would like to store it in a dictionary, but when trying to do so I receive a Property list invalid for format: 200 error. Here is how I try to create the dictionary: NSDictionary *dictionary = [NSDictionary dictionaryWithObject: voiceMemo forKey:@"voiceMemo"]; Same result when trying NSDictionary *dictionary = [NSDictionary dictionaryWithObject: (NSData *) voiceMemo forKey:@"voiceMemo"]; It works, however, when trying to save

Delete an object in core data

醉酒当歌 提交于 2019-12-03 03:42:56
I have an entity in my core data model like this: @interface Selection : NSManagedObject @property (nonatomic, retain) NSString * book_id; @property (nonatomic, retain) NSString * contenu; @property (nonatomic, retain) NSNumber * page_id; @property (nonatomic, retain) NSNumber * nbrOfOccurences; @property (nonatomic, retain) NSString * next; @property (nonatomic, retain) NSString * previous; I have created many Selection s and saved them in Core Data and now I would like to delete some selections with some criteria. For example, I would like to delete a Selection object if matches the

CoreData could not fulfill a fault for

本小妞迷上赌 提交于 2019-12-03 03:37:54
问题 I have a really annoying problem, which I just can't seem to get fixed. I have a view when I send a message that gets saved to the Core Data, when thats done it asked the database for a random message (sentence) and saved that as well to an other row in the database. If I do the last part hardcoded, without fetching data from the DB, it works all fine and dandy, but as soon as I fetch the random row from the DB it goes crazy. In my AppDelegate.m: - (void)save { NSAssert(self.context != nil, @