• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OOP Clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OOP Clarification


  • Subject: Re: OOP Clarification
  • From: jgo <email@hidden>
  • Date: Wed, 2 Jan 2002 18:30:07 -0800

> I've read about the difference between a class method and a instance method
> before, but the difference has somehow become lost in my cobwebs. All I can
> remember is the difference is subtle, but an important concept.
>
> I can't find a good resource. Anyone know a good
> reference/definition/example of the difference?

<http://www.toastedmarshmallow.com> has some good words on the subject.

Here are mine:
Unlike C++, in Objective C certain methods are thought of as
belonging to the class itself, rather than to instantiated objects.
Commonly these are "factory methods" used to do instantiating
(but there can be class methods that are not factory methods).
They're designated by a plus sign at the beginning of their
declarations & definitions. When they are invoked (when you
"send a message to them", you might do it like this
[classname methodname]
NSButton * myButton = [[NSButton alloc] init];

Instance methods, are associated with already instantiated objects.
[instancename methodname]
[myButton setState:NSOnState];

John G. Otto, Eagle Scout, Knight, Cybernetic Praxeologist
Existence, Consciousness, Identity, Life, Liberty, Property, Privacy, Justice


  • Prev by Date: Re: Translating filenames for command line?
  • Next by Date: Re: Testing, Testing; an Apology
  • Previous by thread: Re: OOP Clarification
  • Next by thread: RE: OOP Clarification
  • Index(es):
    • Date
    • Thread