• 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: Forcing allocation of a subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing allocation of a subclass


  • Subject: Re: Forcing allocation of a subclass
  • From: Michael Ash <email@hidden>
  • Date: Sun, 25 Jan 2009 10:23:31 -0500

On Sun, Jan 25, 2009 at 9:31 AM, João Varela <email@hidden> wrote:
> Hi Jean-Daniel
>
> Yes, when I re-read what I wrote I know it can cause confusion. Of course
> 'self' is a pointer to a class instance, not to a class, but I didn't know
> that 'self' was itself a method. Can you point me to the documentation where
> that is written? Of course "+ [NSObject class]" returns a class, not a class
> name (my bad). I said what I said based on listing 2-7 of the page I
> mentioned, but I now realize there is a slight difference with what Antonio
> has posted.
>
> So you mean that
>
> if ( self == [aReceiver class] )
>
> is the same as
>
> if ( [self class] == [aReceiver class] ) ?
>
> If it is, sorry for the noise, but I would find it weird that a pointer to a
> class instance also had the same end result as invoking the NSObject method
> 'class'. Is it?

They are the same *if you are in a class method*.

If the above is in an instance method then no, they are not the same.
The first one will, in fact, never be true.

But if you're in a class method, then 'self' is the class. [self
class] == self in a class method, unless someone has overridden
+class.

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

References: 
 >Re: Forcing allocation of a subclass (From: João Varela <email@hidden>)
 >Re: Forcing allocation of a subclass (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Forcing allocation of a subclass (From: João Varela <email@hidden>)

  • Prev by Date: Re: Using the security framework
  • Next by Date: Re: Knowing when a NSArrayController is ready
  • Previous by thread: Re: Class introspection [was Re: Forcing allocation of a subclass]
  • Next by thread: Re: Forcing allocation of a subclass
  • Index(es):
    • Date
    • Thread