Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So i've got some JSON data and I want to maintain the order in which that data is received with restkit and managed objects and I havent been able to find the best way of doing this. When the order changes I need to make sure duplicates are not created and they are saved properly with core data.

I believe an extra field in the datamodel for this specific entity is needed, lets call it order, and assume is assigned when creating the RKEntityMapping. I'm just not sure how to get the array index using restkit.

Any help appreciated, thanks.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

The index of each object in the response array is provided to the mapping via metadata. Add something like this to your mapping:

@"@metadata.mapping.collectionIndex" : @"order"

There is a bit more information on metadata in the 'Metadata Mapping' section of the RKMappingOperation docs

share|improve this answer
    
worked, thanks! –  tinyfugu Jun 13 '13 at 23:00
    
Yeah that is pretty nice. –  Roderic Campbell Feb 3 at 22:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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