What’s the difference between these two?
[SomeClass.classMethod instanceMethod];
[[SomeClass classMethod] instanceMethod];
classMethod of SomeClass returns a singleton object, on which the instanceMethod is called. Both methods work, and Xcode doesn’t complain during execution or in code. However, typing SomeClass.classMethod doesn’t show any matches in the dropdown whereas [SomeClass classMethod] does. Is this just a missing feature or a deliberate attempt to prevent this kind of practice?
The dot syntax (
SomeClass.classMethod) is just a syntax sugar for sending message ([SomeClass classMethod]). They do equal things.You don’t see completions for properties (dot syntax) probably because the object you are trying to access property of, is not properly casted to the type having that property:
This happens because the
delegateis anidand thus has no properties (it’s object of a generic type), so autocompletion can’t suggest anything. The latter one is sending message to the object of generic type, so the compiler can suggest you lots of messages to send (no matter whether that object supports them).