如何将 NSMutableArray 转换为 NSArray? [英] How do I convert NSMutableArray to NSArray?

查看:25
本文介绍了如何将 NSMutableArray 转换为 NSArray?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 ?

推荐答案

NSArray *array = [mutableArray copy];

Copy 制作不可变的副本.这非常有用,因为 Apple 可以进行各种优化.例如将 copy 发送到不可变数组只保留对象并返回 self.

Copy makes immutable copies. This is quite useful because Apple can make various optimizations. For example sending copy to a immutable array only retains the object and returns self.

如果您不使用垃圾收集或 ARC,请记住 -copy 保留对象.

If you don't use garbage collection or ARC remember that -copy retains the object.

这篇关于如何将 NSMutableArray 转换为 NSArray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆