use*_*619 0 iphone objective-c ios4 ios ios5
我有一个包含UIButtons的NSMutableArray.我给每个按钮一个独特的标签.这些按钮将以随机顺序添加到数组中,但我希望稍后对其进行排序,以使按钮按照标签的升序排列.
谢谢您的帮助!
叶氏.
试试这个:
NSSortDescriptor *ascendingSort = [[NSSortDescriptor alloc] initWithKey:@"tag" ascending:YES];
NSSortDescriptor *descendingSort = [[NSSortDescriptor alloc] initWithKey:@"tag" ascending:NO];
NSArray *sortedArray = [someArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:ascendingSort]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
871 次 |
| 最近记录: |