-arrayWithArray 实际上是做什么的?

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 实际上是做什么的?

基础教程推荐