开发者

NSMutableArray to NSArray in objective C [duplicate]

开发者 https://www.devze.com 2023-04-01 04:04 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How do I convert NSMutableArray to NSArray?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How do I convert NSMutableArray to NSArray?

How can I Convert NSMutableArray to开发者_StackOverflow社区 NSArray in Objective C. i.e. without using loop that addObjects one by one.


An NSMutableArray is an NSArray already (as it's a subclass of NSArray), but if you really need to create a new immutable instance you can do:

NSArray *myArray = [NSArray arrayWithArray:myMutableArray];


How about this code?

NSArray* array = [NSArray arrayWithArray:myMutableArray];
0

精彩评论

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

关注公众号