3 ms·
That ## vals syntax is new to me. What's the difference with the following? #define MD(...) [NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, ni
by stephth 15y ago
That ## vals syntax is new to me. What's the difference with the following?
#define MD(...) [NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
- hboon 15y agoBoth of them wouldn't work for MD() due to the trailing nil. But for MD(val, key, vals...), it'd give you a slightly better error, complaining about the number of arguments when you do MD(). Otherwise they are the same in this case. ## removes one non-whitespace character – often the comma – before the ## if vals or __VA_ARGS__ is empty. e.g #define MO_LogDebug(fmt, ...) NSLog((@"DEBUG " fmt), ##__VA_ARGS__) MO_LogDebug(@"This works as expected %d", resultCode); // Removes the comma automatically in here: // NSLog((@"DEBUG " @"This works too without args"), ); MO_LogDebug(@"This works too without args");