Re: Method Explanation
Re: Method Explanation
- Subject: Re: Method Explanation
- From: Daniel Staal <email@hidden>
- Date: Sat, 12 Apr 2008 15:33:26 -0400
--As of April 11, 2008 5:31:08 PM -0700, Kevin Ferguson is alleged to have
said:
Now, I'm entirely self-taught in Cocoa, so this may be something more
obvious than I think. Is there a reason for this occurrence? I assume
it's got something to do with the +, but not knowing what the + means, or
why my method must be a + to work, I can't really determine what to do.
Can this be explained at all, or can anyone point me to a place that
would explain it?
--As for the rest, it is mine.
Methods with a '-' are 'instance' methods: They operate within a specific
object, using it's data. Methods with '+' are 'class' methods: They do not
need a specific object to work, but will work on the class itself.
Typically, the only reason to use the latter is to have a custom
initializer or convience method to return a new object. (Where they call
'alloc/init' inside them, and then set up some beginning state in some
unique way, that isn't the default.)
All this is in the Obj-C/Cocoa basics materials on Apple's site.
Daniel T. Staal
---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden