Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define array in Macros in Objective-c?

Is there any possibility to define arrays in macro in objective-c.

like image 442
sairam Avatar asked Sep 12 '12 07:09

sairam


2 Answers

Yes, you can define arrays in macros. e.g

#define MY_ARRAY [NSMutableArray arrayWithObjects:someObj1, someObj2, nil]
like image 178
Ehsan Avatar answered Oct 14 '22 13:10

Ehsan


You can also just do:

#define MY_ARRAY @[ @"foo", @"bar" ]
like image 21
Myxtic Avatar answered Oct 14 '22 13:10

Myxtic