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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 190k
  • Answers 190k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check out the official Microsoft forums May 12, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer Looking at this doc, I would think multiplying tv_usec by… May 12, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer The issue of pDataList's elements being adjacent in memory is… May 12, 2026 at 5:55 pm

Related Questions

I've just started learning Obj-C. As an alternative to the usual maths examples, I
I am writing a Cocoa application with Mono embedded. I want to run and
I am developing a cocoa application that will be making heavy use of both
I am developing a Cocoa application which communicates constantly with a web service to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.