• 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: Dave <email@hidden>
  • Date: Mon, 11 Mar 2013 20:49:51 +0000


On 11 Mar 2013, at 20:45, Mike Abdullah wrote:


On 11 Mar 2013, at 20:33, Dave <email@hidden> wrote:


On 11 Mar 2013, at 20:26, Mike Abdullah wrote:

I had assumed (and I thought I'd done something like this before) that the:

myDict = [[super class] newDict];

statement would call newDict in BaseClass???? Instead it calls the version in NewClass and goes into an infinite loop!!

Yes. [super class] calls super's implementation of the -class method. You haven't overridden -class, so it does the same thing as [self class].

People often make the same mistake in trying to do [super respondsToSelector…

I'm guessing what you're really after is [[self superclass] newDict]


Thanks a Million, yes that's what I wanted!

There isn't a

-newDict

method defined, so how come I didn't get a complier error?

Because your code was still calling +newDict, just not on the class you wanted.

I got a little confused by your code. Realise where I said -class up above, that should actually be +class.

As others have pointed out [super newDict] might well be what you want also/instead.


Confused now, I thought you meant +.

There is no instance of the class to call [super newDict] on?

There is no:

-NewDict method, just +newDict.

So, surely [super newDict] should error? Since I assume that super is in this case a class not an object???

I want to call the class + method of the NewClass and have it call the class + mehod of BaseClass?

Cheers
Dave




_______________________________________________

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


  • Follow-Ups:
    • Re: Objective-C Question
      • From: Mike Abdullah <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: Mike Abdullah <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