• 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: Objective-C Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C Question


  • Subject: Re: Objective-C Question
  • From: Keary Suska <email@hidden>
  • Date: Mon, 11 Mar 2013 15:26:18 -0600

On Mar 11, 2013, at 2:55 PM, Dave wrote:

> On 11 Mar 2013, at 20:50, Jens Alfke wrote:
>
>>
>> On Mar 11, 2013, at 1:33 PM, Dave <email@hidden> wrote:
>>
>>> There isn't a
>>> -newDict
>>> method defined, so how come I didn't get a complier error?
>>
>> Because the receiver is a Class, so the method is +newDict, which exists.

To be clear, my language here could be rather loose, but it is how I understand it. I am sure other ion the list will correct where my language is misleading. Anyway...

> Not sure I understand:
>
> if from an Instance - Method, I do:
>
> [super someMehod];
>
> It calls -someMehod in the superclass.

More specifically, it calls the superclass' *implementation* of the method. Subtle, but important difference that explains Dave's response.

> if from an instance  + Method I do:
>
> [super someMethod], then surely it's an error because this isn't an instance?

No, because "super" works similarly in class methods as instance methods. It is not only for instances. It is the same for "self"--in a class method it refers to the current class.

> So from a + method, what do:
>
> [super someMethod]; and

This calls the implementation of the method as defined in the superclass, but calls it in the context of the current class. It is the same as calling [CurrentClass someMethod] except that the method *implementation* used is the one defined by the superclass. Therefore, any reference to "self" in the method implementation will resolve to the current class, not the super class.

> [[self superclass] someMethod];


This specifically invokes the superclass' method, in the superclass' context. It is the same as calling [SuperClass someMethod]

Any help?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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: 
 >Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: Mike Abdullah <email@hidden>)
 >Re: Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: Jens Alfke <email@hidden>)
 >Re: Objective-C Question (From: Dave <email@hidden>)

  • Prev by Date: Re: Objective-C Question
  • Next by Date: Re: Objective-C Question
  • Previous by thread: Re: Objective-C Question
  • Next by thread: Re: Objective-C Question
  • Index(es):
    • Date
    • Thread