As of Xcode 7.3.1, there is currently no difference between:
- (void)foo:(NSInteger)__unused myInt;// [syntax 1]
- (void)foo:(NSInteger __unused)myInt;// [syntax 2]
- (void)foo:(__unused NSInteger)myInt;// [syntax 3]
But the following doesn't work:
- (void)foo:(NSInteger)myInt __unused;// [doesn't work]
For usage on this, Apple recommends first syntax. (information was partially taken from this answer)
But there is difference between:
__unused NSString *foo, *bar; // [case a] attribute applies to foo and bar
NSString *foo __unused, *bar; // [case b] attribute applies to foo only
NSString * __unused foo, *bar; // [case c] attribute applies to foo only
NSString __unused *foo, *bar; // [case d] attribute applies to foo and bar
CFStringRef __unused foo, bar; // [case e] attribute applies to foo and bar
If we want __unused
to apply to all, syntax [a] is my personal best as it leaves no ambiguity.
If we want __unused
to apply to one, syntax [b] is my personal best as it leaves no ambiguity.
The latter three solutions are acceptable but confusing in my opinion. (information was partially taken from this answer)
And while we're talking about the order of keywords, kind reminder:
const NSString *foo = bar; // BAD: foo is NOT const
NSString const *foo = bar; // BAD: foo is NOT const
NSString *const foo = bar; // GOOD: foo is const