Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I cannot comment, thats why i am creating an answer.</p> <p>Why don't you create the subclass for your entities using the xcode and import their header files and use code like below</p> <pre><code> //Save values //NSMutableSet* values = [[NSMutableSet alloc] init]; -- No Need of this for(NSString* n in gameData.values){ Value *val = [NSEntityDescription insertNewObjectForEntityForName:@"Value" inManagedObjectContext:context]; [val setValue:n]; // set your string [val setGame:gd]; // set the game relation here. you can do this, if you have </code></pre> <p>configured inverse relations. If no create inverse relationship it will be helpful.</p> <pre><code> } //[gd setValue:values forKey:@"values"]; you don't need this. </code></pre> <p>Now just save the context. Everything should be fine. This is much more cleaner than your way. I have never ever used key value for accessing core data entity properties because, it will be confusing and error prone as you have to remember the exact spelling of the property, and it wont throw any error if you have used wrong spelling or wrong key. </p> <p>i think you should look at <a href="http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/CoreData/cdProgrammingGuide.html#//apple_ref/doc/uid/TP30001200-SW1" rel="nofollow">core data programming guide</a></p> <p><strong>Edit:</strong> If your GameEntity stores array of strings then one to many relationship is just enough. You need many to many only if GameEntity has many Strings and Each Strings i.e. Value entity also has many GameEntity. In that case the above code slightly changes.</p> <p>Instead of </p> <pre><code>[val setGame:gd]; </code></pre> <p>You need to use</p> <pre><code>[val addGameObject:gd]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload