Reputation: 12527
Is it possible to pass an array as an argument for a function?
Upvotes: 6
Views: 16233
Reputation: 33197
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];
Upvotes: 20