Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does -arrayWithArray actually DO?

I want to see EXACTLY how it creates an array. How can I view the .m files that show how it's done?

like image 879
RexOnRoids Avatar asked Sep 08 '09 04:09

RexOnRoids


People also ask

What is actually used for?

Actually as a discourse marker Spoken English: Actually is often used in speaking as a discourse marker. We use it to indicate a new topic of conversation or a change or contrast in what is being talked about. We also use actually to give more detail about a topic.

What do you do actually meaning?

"What do you do" is a way to ask someone what their job is or what they do for a living. It is a polite question to ask when you first meet someone, or when you are getting to know someone new, or when you haven't seen someone for a long time.

Does actually mean really?

Actually is an adverb that means "really."

What does it mean when someone says actually?

1 : in act or in fact : really trying to find out what actually happened won't actually arrive for an hour. 2 : in point of fact —used to suggest something unexpected was surprised to learn that she could actually speak German.


1 Answers

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 :-).

like image 169
Nathan de Vries Avatar answered Oct 23 '22 02:10

Nathan de Vries