Core Data - Order of objects in a to-many relationship

Eyal

My app is a music library app, the user has their songs, and they can create playlists.
I want the order of the songs in the playlist to be in the order that the user adds those songs to that playlist.

My core data objects:

Song
=====
name
duration
album

artist (to one relationship)

Playlist
========
title

songs (to many relationship)  

I have a tableview of playlists, each row in that table shows the title of the playlist and the name of the last song added to that playlist.

I have two questions:

  1. How can i know what was the last song the user added to the playlist? even more how can I know the order of the songs in a given playlist?
  2. How should I fetch that last song name when i'm building the playlists tableview?
Paul.s

Set the relationship type to ordered in the core data editor. This will mean that you now get an NSOrderedSet of songs instead of just an NSSet of songs

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Core Data: Fetching related objects in many-to-many relationship

From Dev

Getting objects from to-many relationship in Swift Core Data

From Dev

Many to many relationship to self in Core Data (iOS)

From Dev

Core data: NSFetchedResultsController with objects are in a relationship

From Dev

One to many relationship with objects using EF core

From Dev

How to Only Add Objects with Distinct Attributes to Core Data to-many Relationship NSSet

From Dev

Core-Data NSFetchedResultsController to-many relationship

From Dev

Core Data one-to-many inverse relationship

From Dev

Core Data - sectionNameKeyPath with a One to Many Relationship

From Dev

Core data one to many relationship in swift

From Dev

Core Data to-many relationship filterContentForSearchText with NSPredicate

From Dev

unwanted objects appearing in core data relationship

From Dev

IOS/Core-Data: add many to many relationship

From Dev

Allowing duplicate records in Core Data Many-to-many relationship

From Dev

Many to many relationship core data query for specific collection

From Dev

How to make a many to many relationship in core data in the .xcdatamodel

From Dev

Best practice for preloading core data with many to many relationship

From Dev

many to many relationship update data mvc .net core

From Dev

Entity framework core: Retrieve data to view in Many to many relationship

From Dev

Core Data Many-to-Many relationship update causes fault

From Dev

Assign array of items to selected item - Many to Many relationship in core data

From Dev

How to add many objects into core data?

From Dev

inputing many objects into core data in one go

From Dev

saving, deleting and fetching data from a one to many relationship core data

From Dev

core data save records using to-many relationship?

From Dev

Core Data One to Many Relationship: unrecognized selector sent to instance

From Dev

Core data - info about to-many relationship properties

From Dev

How to filter entities by many relationship count using SUBQUERY in Core Data

From Dev

swift core data relationship one to many for own entity

Related Related

  1. 1

    Core Data: Fetching related objects in many-to-many relationship

  2. 2

    Getting objects from to-many relationship in Swift Core Data

  3. 3

    Many to many relationship to self in Core Data (iOS)

  4. 4

    Core data: NSFetchedResultsController with objects are in a relationship

  5. 5

    One to many relationship with objects using EF core

  6. 6

    How to Only Add Objects with Distinct Attributes to Core Data to-many Relationship NSSet

  7. 7

    Core-Data NSFetchedResultsController to-many relationship

  8. 8

    Core Data one-to-many inverse relationship

  9. 9

    Core Data - sectionNameKeyPath with a One to Many Relationship

  10. 10

    Core data one to many relationship in swift

  11. 11

    Core Data to-many relationship filterContentForSearchText with NSPredicate

  12. 12

    unwanted objects appearing in core data relationship

  13. 13

    IOS/Core-Data: add many to many relationship

  14. 14

    Allowing duplicate records in Core Data Many-to-many relationship

  15. 15

    Many to many relationship core data query for specific collection

  16. 16

    How to make a many to many relationship in core data in the .xcdatamodel

  17. 17

    Best practice for preloading core data with many to many relationship

  18. 18

    many to many relationship update data mvc .net core

  19. 19

    Entity framework core: Retrieve data to view in Many to many relationship

  20. 20

    Core Data Many-to-Many relationship update causes fault

  21. 21

    Assign array of items to selected item - Many to Many relationship in core data

  22. 22

    How to add many objects into core data?

  23. 23

    inputing many objects into core data in one go

  24. 24

    saving, deleting and fetching data from a one to many relationship core data

  25. 25

    core data save records using to-many relationship?

  26. 26

    Core Data One to Many Relationship: unrecognized selector sent to instance

  27. 27

    Core data - info about to-many relationship properties

  28. 28

    How to filter entities by many relationship count using SUBQUERY in Core Data

  29. 29

    swift core data relationship one to many for own entity

HotTag

Archive