Re: NSService - I need a headslap
Re: NSService - I need a headslap
- Subject: Re: NSService - I need a headslap
- From: Michael Ash <email@hidden>
- Date: Wed, 4 Feb 2009 17:55:56 -0500
On Wed, Feb 4, 2009 at 10:03 AM, Steve Cronin <email@hidden> wrote:
> Well, sheesh - that's embarrassing! There is no 'self' until init - I know
> that! Ugh.
Sure there is. There's a 'self' in every method. It refers to the
receiver of the message that was sent. In instance methods, 'self'
refers to the instance. In class methods, 'self' refers to the class.
Example:
@implementation Foo
+ foo {
NSLog(@"self is %@ (%p) and Foo is %@ (%p)", self, self, [Foo
class], [Foo class]);
}
@end
You'll get the same values for both, since they give you the same thing.
Of course it's the class, not the instance, so the self you have isn't
the self you *wanted* here.
Mike
_______________________________________________
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