本文介绍了-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所提到的,你看不到source(虽然你可以通过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究竟做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!