Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective - C -> Pass Array As Function Argument

Is it possible to pass an array as an argument for a function?

like image 256
user559142 Avatar asked Jul 08 '11 18:07

user559142


1 Answers

Yes, of course.

C-array:

- (void)myFunction:(int*)array;
 ...

int bar[12];
[obj myFunction:bar];

NSArray:

- (void)myFunctionWithNSArray:(NSArray*)array;
...
NSArray *array = [[NSArray alloc] initWithObjects...];
[obj myFunctionWithNSArray:array];
like image 78
Yann Ramin Avatar answered Oct 05 '22 21:10

Yann Ramin