2

I have a database in core data that needs to group items according to their type. Because of that i cant add a item at the end. I need to insert it to a specific index. Can you please tell me how to insert a new record at index x and moving the old index x to index x+1 and so on. Or is there a way to sort the record descending acording to parameter y ?

Thank you

4
  • 2
    That's not the relational database way of doing things. Generally grouping and ordering is defined by the "select/fetch" statement and has nothing to do with storage.
    – trojanfoe
    Apr 24, 2014 at 10:34
  • thank you can u share a link how to fetch data whit ordering ? I found only the clasic store order.
    – WildWorld
    Apr 24, 2014 at 10:43
  • did you check NSFetchedResultsController reference?
    – Eloy
    Apr 24, 2014 at 10:44
  • raywenderlich.com/999/…
    – Eloy
    Apr 24, 2014 at 10:50

1 Answer 1

2

Any concept of order is created by you using an ordering attribute(s) on your entity. It's also entirely up to you to update / maintain that ordering information (and to use it when fetching / processing fetched results).

2
  • can u please tell me or link how to use these ordering atributes ?
    – WildWorld
    Apr 24, 2014 at 10:43
  • There is no standard guide AFAIK, you decide how you want it to work. It could be a simple int value, or a date. And when fetching you use an NSSortDescriptor to specify the attribute key to use and the sort order you want to apply. When 'inserting' objects, you need to write code to add the new and edit (as required) existing object order information.
    – Wain
    Apr 24, 2014 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.