FROM : Jens Alfke
DATE : Thu May 15 16:59:48 2008
On 14 May '08, at 10:16 PM, David Wilson wrote:
> 3) Instance methods (with the -) are virtual functions. Class
> methods (with the +) are static functions.
Class methods aren't exactly like static functions, because they're
still dynamically dispatched and can be overridden by subclasses.
A closer analogy is to think of there being a singleton "class object"
for every class (which is what -class returns), and the class methods
are instance methods of those class objects. The class objects have an
inheritance hierarchy that parallels the class hierarchy, so if B is a
subclass of A, B's class object will be a subclas of A's class object.
(For more detail, look up "metaclass"; I'm sure there's an abstruse
Wikipedia article about it. The concept goes back to Smalltalk-80, on
which Objective-C's runtime model and syntax were based.)
—Jens
PS: In regards to the thread subject, I didn't find Cocoa to have a
steep learning curve. I took a training class and was amazed at how
easy it was to learn, and to build sophisticated apps with, compared
to every other GUI API or framework I'd used.
DATE : Thu May 15 16:59:48 2008
On 14 May '08, at 10:16 PM, David Wilson wrote:
> 3) Instance methods (with the -) are virtual functions. Class
> methods (with the +) are static functions.
Class methods aren't exactly like static functions, because they're
still dynamically dispatched and can be overridden by subclasses.
A closer analogy is to think of there being a singleton "class object"
for every class (which is what -class returns), and the class methods
are instance methods of those class objects. The class objects have an
inheritance hierarchy that parallels the class hierarchy, so if B is a
subclass of A, B's class object will be a subclas of A's class object.
(For more detail, look up "metaclass"; I'm sure there's an abstruse
Wikipedia article about it. The concept goes back to Smalltalk-80, on
which Objective-C's runtime model and syntax were based.)
—Jens
PS: In regards to the thread subject, I didn't find Cocoa to have a
steep learning curve. I took a training class and was amazed at how
easy it was to learn, and to build sophisticated apps with, compared
to every other GUI API or framework I'd used.






Cocoa mail archive

