I am learning how to use macro but now confused with one.
I am trying to create a NSString
concatenate which will just append every params to each other.
for example : concatOP(@"hey",@"Jude",@"Don't")
would return a NSString
containing : @"heyJudeDon't"
I actually made a bit of code (some found here as well) which get the number of params but I don't succeed to make the second part of the job.
#define NUMARGS(...) ( sizeof((int[]){__VA_ARGS__}) / sizeof(int) )
#define concatOP(...) NSMutableString *format = [[NSMutableString alloc] init];\
for( int i = 0; i < NUMARGS(__VA_ARGS__); i++){\
[format appendString:@"%@"];}\
[[NSString alloc] initWithFormat:format, __VA_ARGS__]
I actually get many errors, telling me that format doesn't exist or that I miss some ";" or other ending tags.