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 8077147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:24:55+00:00 2026-06-05T15:24:55+00:00

In Core Data of Xcode 4.3.2, an Ordered To-Many relationship is modelled with NSOrderedSet

  • 0

In Core Data of Xcode 4.3.2, an Ordered To-Many relationship is modelled with NSOrderedSet. It works well until I found the need to have repeated items in the relationship; it should really be modelled in a NSArray.

For example, in a music app, I have the following songs: SongA, SongB, SongC ,

I may want a party play list where people insert songs in any order and could be repeated. The list may look something like:

[SongC, SongC, SongA, SongC]

The way Core Data currently works, the list would become:

[SongC, SongA]

I.e., all repeated items are dropped, as it is modelled with sets.

So, coming back to my question: what is a good way to model repeated items in order in a relationship in Core Data?

  • 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-06-05T15:24:57+00:00Added an answer on June 5, 2026 at 3:24 pm

    Relationships are sets (and ordered relationships are ordered sets, but still sets); sets by definition contain unique objects. So you can’t put duplicate objects into a relationship either way.

    Whether you use the ordered-relation feature or not, you’ll want to go back to the abstract ER model to find another way to turn your conceptual relationships into a Core Data model… it might help to think about how you’d do it in a plain SQL (or SQL-like) database and then come back to what Core Data does beyond SQL.

    It sounds like you’re making something akin to iTunes playlists, no? A model that might work for that would go something like:

     Playlist      <--->> PlaylistEntry
     PlaylistEntry <<---> Song
    

    The PlaylistEntry entity represents one instance of a Song‘s inclusion in one Playlist. You can have multiple PlaylistEntrys that reference the same Song in a single Playlist, and you can add other attributes to the PlaylistEntry to keep track of other things (like song order, if you’re not using an ordered relationship). As a bonus, you can use that to add other features if you like — say, to make a playlist that plays three different snippets out of one long track.

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

Sidebar

Related Questions

IOS5.1 / XCode 4.3 I have 2 entities in my core data, lets call
I am using core data and set up a one to many relationship for
I have been working on a Core Data iOS app that works perfectly through
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
I have created core data database in xcode. i haven't insert any thing in
I have few Core Data projects for MacOS started with Xcode 3 that behaves
I am using this Xcode template for core data. On the delegate, I have
I have been running tests towards a Core Data model (SQLite3). I now need
I have a pretty standard Xcode-generated interface for Core Data objects, namely these properties
I'm creating a data model using xcode and core data. It's an object graph,

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.