Reputation: 7103
I know this is probably a pretty basic question, but I'm working with Core Data and a UITableView. I import all the data from Core Data to various mutable arrays. When a user rearranges the items in the table, it's easy enough to swap the items in the mutable arrays I obtained from core data earlier, but is there an easy way to sync the new mutable array with the existing core data? Any help is appreciated!
Upvotes: 1
Views: 432
Reputation: 17208
Lion added support for ordered to-many relationships, which is much easier than storing the indices within the entities. If you're targeting Lion you can mark the relationship Ordered and access it using a new class NSOrderedSet, which will persist its order, like an array.
Upvotes: 1
Reputation: 80265
I think your question is actually how to persist the order of the data in your table view rows in Core Data.
The answer is you have to introduce a new integer / NSNumber
attribute to keep track. I have done this in a simple app managing a to-do list.
Upvotes: 1
Reputation: 6679
Use a NSFetchedResultsController
. It greatly simplifies using a table view and Core Data together. No need worrying about intermediary arrays.
Upvotes: 1