Dot syntax on Class methods only compiles with public methods
| Originator: | nicolas.bouilleaud | ||
| Number: | rdar://14250868 | Date Originated: | 2013-06-24 |
| Status: | Closed (Behaves correctly) | Resolved: | |
| Product: | Developer Tools | Product Version: | 5.0 |
| Classification: | Other bug | Reproducible: | Always |
Summary:
Given this source :
@interface SomeClass : NSObject
+ (id) classMethod;
@end
@implementation SomeClass
+ (id) classMethod { return nil; }
+ (id) privateClassMethod { return nil; }
@end
This will compile:
SomeClass.classMethod;
However this will not:
SomeClass.privateClassMethod;
Obviously, this will work:
[SomeClass privateClassMethod];
Steps to Reproduce:
Try the above code in Xcode 5, or see attached small source or https://gist.github.com/n-b/5853294
Expected Results:
There is no fundamental difference between classMethod and privateClassMethod. Both should be treated the same way.
Regression:
This has never worked AFAIK.
Notes:
This is related to rdar://14250709
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
This is not my point; I'm just pointing a difference between publicly and privately declared methods. Also, if it is wrong, why does the compiler even accept it?
I do recognize that using the dot-syntax for class methods is seriously awkward, and I would not recommend it.
However, if
SomeClass.classMethodis accepted,SomeClass.privateClassMethodshould be as well. (from within the .m file).You have not understand the dot syntax in Obj-C. the dot syntax is reserved only for the getter and the setter of property variable. It's mistakenly working when the method declaration resemble a getter or a setter. Is wrong try to call a private or a public method with the dot syntax.