How to use Ternary Operators in a Macro in Objective-C?-Collection of common programming errors

The string concatenation with adjacent string literals only works when both are string literals, i.e.

@"foo" @"bar"       is the same as         @"foobar"

because @"foo" and @"bar" are string literals, but

@"foo" (@"bar")     is compiler error

because of the ( in between. This is the same situation as yours. In this case, you’d better concatenate the two strings in runtime:

#define LoginPageUrl    [BaseURL stringByAppendingString:(QueryStringParam)]

or force the compiler to see two adjacent string literals by combining the BaseURL and QueryStringParam

#define LoginPageUrl \
    ((UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) ? \
        BaseURL @"deviceType=iPad" : \
        BaseURL @"deviceType=iPhone")