iphone - Core Data simple relationship in code -
I'm a cocoa newbie trying to create an iPhone app with core data.
My problem is this: I have a small app that is now called a playlist with a single unit which I can show in table view and add and delete entries.
playlistListManagedObjectContext
playlistListPersistentStoreCoordinator
playlistManagedObjectModel
I have in my PlayerAppDelegate: Adding the unit with:
Now I want to add a cable which is called songs with multiple relationships.
Playlist attribute added: SongRelation Songs Properties added: playlistRelation
I have created this unit and relationships are established in both ways, to the click of the alternative flag as I have less Want less one song in a playlist?
After setting this relationship, now I can make a playlist without a warning. The problem is that "this" wants to prepare a song too, but I do not know how.
I can not find a place in this situation with an example of adding a new playlist, that is, when it is connected to another entity which can be added
I create these Will:
songManagedObjectModel songListManagedObjectContext songListPersistentStoreCoordinator
Or can the unit of playlist be accessed through any kind of playlist unit?
Something like this:
Add playlists
Add songs
Set up "Relationship" attributes (how?)
Save to Continuous Store
or ????
I have really gone a lot and probably thought of something basic because there are no examples available here ....
Rgds PM
PETER,
There should be a way to playlist model object like this:
- (zero) addSongObject: (song *) value;
This is a dynamically designed method that will include song value in relation to songs in the playlist. If you have not created a playlist model object by connecting the relationship of the song, then that method will not be there. So, make sure that you generate model squares for any converted units
The purpose of the song is to be created using ManagedObjectContext as you pass the addSongObject method.
Song * song = (song *) [NSEntityDescription insertNewObjectForEntityForName: @ "song" inManagedObjectContext: playlistListManagedObjectContext];
jack
Comments
Post a Comment