Question

Every time I Save a new Object it appears on the top of my UITableView. What If want it to apper at a different index path or different section?

For Example is it Possible to insert the new Object at:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[[self objectsFetched] count]-1 inSection:0];

or

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[[self objectsFetched] count]-1 inSection:1];

I Can accomplish the above scenario with NSMutableArrays, but how do I achieve the same with Core Data?

Was it helpful?

Solution

With Core Data you have a big bag of contents, how you display that in a table view is entirely up to you. The process of achieving this is by sorting the big bag, generally as you extract the contents.

Look at NSFetchRequest and you will see it takes an array of sortDescriptors. You can make these sort descriptors look at any key in your managed objects. If you want, you can add an explicit order key and set the value, or a date stamp.

How you sort is up to you, but you do need to sort to specify the order you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top