欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

NSArray转为NSMutableArray

程序员文章站 2022-07-14 16:48:28
...
NSDictionary *names;
NSMutableArray *keys;  


NSString *path = [[NSBundle mainBundle] pathForResource:@"sortednames" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
names = dict;
   
NSMutableArray *array;
[array setArray:[[names allKeys] sortedArrayUsingSelector:@selector(compare:)]];
self.keys = array;
 

 

參考:

 

setArray:
Sets the receiver’s elements to those in another given array.

- (void)setArray:(NSArray *)otherArray

Parameters
otherArray
The array of objects with which to replace the receiver's content.