Objective C - Sort an array of string

后端 未结 3 1414
长发绾君心
长发绾君心 2021-01-03 22:43

I have to sort an array of objects by a property of the objects that is a string. How can I do this?

3条回答
  •  别那么骄傲
    2021-01-03 23:13

    you need to use

    -[NSArray sortedArrayUsingSelector:]
    

    or

    -[NSMutableArray sortUsingSelector:] and pass @selector(compare:) as the parameter.

    here's a link to the answer Sort NSArray of date strings or objects

提交回复
热议问题