Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 289405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:54:14+00:00 2026-05-12T05:54:14+00:00

I am a cocoa newbie trying to create an iPhone app including Core Data.

  • 0

I am a cocoa newbie trying to create an iPhone app including Core Data.

My problem is this: I have a little app running now with a single entity called Playlist that I display in a table view and can add and delete entries in.

I have these in my PlayerAppDelegate:

playlistManagedObjectModel

playlistListManagedObjectContext

playlistListPersistentStoreCoordinator

Adding entity with:

Playlist *playlist = (Playlist *)[NSEntityDescription
    insertNewObjectForEntityForName:@"Playlist" 
             inManagedObjectContext:playlistListManagedObjectContext];

Now I want to add a sublevel called Song with a to-many relation.

Playlist attribute added: songRelation
Song attribute added: playlistRelation

I have created this entity and set up the relations both ways, clicking of the Optional flag as I want to have at least one Song in a Playlist.

After setting this relation I can now no longer create a Playlist without getting a warning. The problem is that “it” wants a Song created too, but I dont know how.

I cant find a single place with an example on how to add a new playlist in this case, ie when is has a relation to another entity that has to be added too.

Do I need to create these:

songManagedObjectModel
songListManagedObjectContext
songListPersistentStoreCoordinator

or is the Song entity accessible via the playlist entity somehow?

Something like this perhaps:

Add Playlist

Add Song

Set up “relation” attributes (how?)

Save to persistent store

Or????

I have really googled a lot and has probably misunderstood something basic here since there are no examples available….

Rgds
PM

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:54:14+00:00Added an answer on May 12, 2026 at 5:54 am

    Petter,

    There should be a method on the PlayList model object that is something like:

    - (void) addSongObject:(Song *)value;
    

    It is a dynamically generated method that will insert a Song value into the relationship for songs in PlayList. If you have not generated the PlayList model object since adding the Song relationship, that method will not be there. So, make sure you generate model classes for any changed entities.

    The Song object that you pass to the addSongObject method should be created using the ManagedObjectContext like:

    Song *song = (Song *)[NSEntityDescription insertNewObjectForEntityForName:@"Song" inManagedObjectContext:playlistListManagedObjectContext];
    

    Jack

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m newbie. I have three xib files in my cocoa app: MainMenu.xib the main
My Cocoa app needs some small dynamically generated windows. How can I programmatically create
I have a Cocoa app that uses a WebView to display an HTML interface.
Hey, Im a newbie in cocoa and I have a string and I am
Cocoa newbie here. I am working on an iPhone UITableViewController-based widget that can be
Cocoa newbie here... I know this sounds stupid but I can't find the Bindings
Cocoa app, SnowLeopard I have a WebView in to which I'm loading HTML (essentially
I have a Cocoa document-based app that (currently at least) functions as a basic
Disclaimer: Cocoa newbie here. I wrote an app with a Cocoa GUI that acts
I'm quite a newbie to Cocoa & Mac programming. I have a WebView and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.