I want to define a macro or some other way I can generate similar variable declarations in compile-time. E.g. I want to declare 50 NSString variables like so : #define VAR_GENERATOR (var_name, var_content) NSString* var_name = @"var_content" and do it in a for loop:
for(NSString* string in [stringArray count])
{
NSString* var_name = [NSString stringWithFormat: @"string%d", iteration];
VAR_GENERATOR (var_name, string);
iteration++;
}
Let's say [stringArray count] == 50 so I want to have 50 NSString variables declarations like so: NSString* string1 = @"first string from array" and so on...
So are there some preprocessor ways I can achieve this? Or may be there are some other more elegant and flexible compile-time metaprogramming tools in Objective-C?