what does -arrayWithArray actually DO?(-arrayWithArray 实际上是做什么的?)
本文介绍了-arrayWithArray 实际上是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想看看它是如何创建一个数组的.如何查看显示其完成方式的 .m 文件?
I want to see EXACTLY how it creates an array. How can I view the .m files that show how it's done?
推荐答案
正如@Ken 提到的,你看不到源代码(虽然你可以通过gdb 反汇编方法).
As @Ken mentioned, you can't see the source (although you can disassemble the method via gdb).
该方法本身会创建给定数组的不可变(无法更改)、自动释放副本.以下行为相同:
The method itself creates an immutable (can't be changed), autoreleased copy of the given array. The following are identical in behavior:
// Both resulting arrays are immutable and won't be retained
NSArray* immutableArray = [[[NSArray alloc] initWithArray:mutableArray] autorelease];
NSArray* immutableArray = [NSArray arrayWithArray:mutableArray];
NSArray* immutableArray = [[mutableArray copy] autorelease];
我猜,请根据简洁性来选择你喜欢的那个:-).
Pick whichever one you like based on brevity, I guess :-).
这篇关于-arrayWithArray 实际上是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:-arrayWithArray 实际上是做什么的?


猜你喜欢
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01