About the object sequence in the RestKit

喜欢而已 提交于 2019-11-28 10:39:20

问题


I recently used RestKit to handle my net request affairs. There is a solution for the sort with the sort descriptor. But there is no sort key for the data sent by the server.

How can I keep the data in the same sequence as the server.

There is a solution that I can add a sortID in the object, but this is not very elegant. I want to know if there is any api in RestKit for this problem?


回答1:


You should add sortID to the object - this is the appropriate solution. To populate it with a value you need to use the @metadata made available to your mappings:

@"@metadata.mapping.collectionIndex" : @"sortID"

This code assumes that you are specifying your mapping with a dictionary (addAttributeMappingsFromDictionary:).

Documented here, the collectionIndex provides you with an NSNumber representing the order of the item in the response data.



来源:https://stackoverflow.com/questions/20237615/about-the-object-sequence-in-the-restkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!