开发者

reorder NSArray in objective-c

开发者 https://www.devze.com 2022-12-31 02:30 出处:网络
I have an NSArray of JSONfile locations. There are stored in the 开发者_Python百科user\'s/app\'s Document directory and inside each JSON file is a name value.

I have an NSArray of JSON file locations. There are stored in the 开发者_Python百科user's/app's Document directory and inside each JSON file is a name value.

I'm able to retreive the data from JSON files, I don't need help with tht. But I need help on sorting NSArrays I have no idea how I can do that based on a value inside the file, while not being pathetically slow.

This is on the iPhone btw.

In sum how do I customly reorder NSArrays.


NSArray contents are immutable, but there are several methods for creating a sorted copy of the array, like sortedArrayUsingFunction:context:, sortedArrayUsingSelector: or sortedArrayUsingDescriptors:

Note that the new sorted array does not copy the elements of the original done, it just retains them.

0

精彩评论

暂无评论...
验证码 换一张
取 消