user5812721 user5812721 - 4 months ago 5
Objective-C Question

What does this #define in Objective C do?

I've found that

s can be used in Objective C to make a longer function smaller, but I'm not sure what it does here:

#define S(s) @#s

Later in the code the developer uses it in:

self.scopeDisplayNames = @[S(SPTAuthUserReadPrivateScope), S(SPTAuthUserReadEmailScope)];

I'm very confused as to what it does. Also, is there a way to do this in Swift?



It declares a macro function that turns the parameter into a NSString literal. For example, S(hi) would expand to @"hi".

For reference:

And to answer your second question, there is no way to do this in Swift that I am aware of. It's not a good idea in either language, anyway.