Created
June 24, 2013 20:24
-
-
Save n-b/5853294 to your computer and use it in GitHub Desktop.
Sample code for a couple of Radars on dot-syntax: rdar://14250868 Dot syntax on Class methods only compiles with public methods rdar://14250709 Xcode does not always autocomplete the dot-syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The behaviour for dot-syntax is inconsistent in two aspects. | |
// | |
// 1. Autocompletion | |
// @properties and instance methods declared in the @interface block are autocompleted in Xcode with the dot-syntax; | |
// However class methods and private instance method are not autocompleted, although they are perfectly valid. | |
// | |
// Moreover, the class method are suggested in autocompletion after an instance variable. | |
// (in the example below, that would be instance.classMethod. | |
// | |
// Autocompletion should be suggested whenever the syntax is valid. | |
// | |
// 2. Private class method don't support dot-syntax | |
// Public class method (as in SomeClass.classMethod) support the dot-syntax, | |
// but private class method will *not* compile using dot-syntax, and must be written using the regular []. | |
// (e.g., [SomeClass privateClassMethod] will compile, not SomeClass.privateClassMethod. | |
// | |
#import <Foundation/Foundation.h> | |
@interface SomeClass : NSObject | |
@property (readonly) id instanceProperty; | |
- (id) instanceMethod; | |
+ (id) classMethod; | |
@end | |
@implementation SomeClass | |
- (id) instanceProperty { return nil; } | |
- (id) instanceMethod { return nil; } | |
- (id) privateInstanceMethod { return nil; } | |
+ (id) classMethod { return nil; } | |
+ (id) privateClassMethod { return nil; } | |
@end | |
int main(int argc, const char * argv[]){ | |
@autoreleasepool { | |
SomeClass * instance = [SomeClass new]; | |
NSLog(@"property : autocompletion enabled. %@",instance.instanceProperty); | |
NSLog(@"public instance method : autocompletion enabled. %@",instance.instanceMethod); | |
NSLog(@"private instance method : no autocompletion. %@",instance.privateInstanceMethod); | |
NSLog(@"class method : no autocompletion. %@", SomeClass.classMethod); | |
NSLog(@"private class method : would not compile with dot-syntax. %@", [SomeClass privateClassMethod]); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment