-1

I am using RestKit to download data from an API, namely an array of book descriptions. In my app, this data is read-only. I need that the user can mark some of the items downloaded as favourites.

I would like to save this bookmarks also in Core Data in a way that permits to use a NSPredicate to fetch only favourite books.

I can't just add a favourite field in the books entity because its value would be overwritten each time the app downloads data from server. I guess I need a different entity and I must establish a relationship between them but I couldn't find the right way.

How could I address this? Thanks for your help.

1 Answers1

0

Each of your books must have an identifier property. Simply create a list of the identifiers of the favourite books. You probably don't even want to store this in Core Data. Instead, store it in an NSArray and store it in NSUserDefaults.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Thanks Wain. To store favourites in NSUserDefaults is my current solution. I wondered if I could store that in Core Data to be able to create a NSPredicate that returns just the favourite books and not all. – davidhernando Jun 04 '13 at 09:44
  • You could yes. Storing it in Core Data should allow the predicate to deal with more favourites too. – Wain Jun 04 '13 at 10:19