How to maintain order of JSON arrays with Restkit managed objects

So, I have some JSON data, and I want to keep the order in which this data will be obtained using restkit and managed objects, and I could not find a better way to do this. When the order changes, I need to make sure that duplicates are not created, and that they are saved correctly with the kernel data.

I believe that an additional field in the datamodel for this particular object is necessary, it allows you to call its order and assume that it is assigned when creating RKEntityMapping. I'm just not sure how to get the index of an array using restkit.

Any thanks, thanks.

+7
source share
1 answer

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

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

For more information on metadata, see the "Metadata Mapping" RKMappingOperation docs.

+12
source

All Articles