• 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: Simple but fundamental question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple but fundamental question


  • Subject: Re: Simple but fundamental question
  • From: Andre <email@hidden>
  • Date: Wed, 1 Feb 2006 10:58:44 -0800

Scott Thompson/Guy Umbright wrote:


On Feb 1, 2006, at 5:06 AM, email@hidden wrote:

I have a simple question, but means a lot to me.
That is, if I call a method of super, like [super goAway] and - goAway calls a method on self, like [self blowUp], and - blowUp is subclassed in the same class that called the original method, super's call would call my subclassed method?

That's what I would expect.

Is supers' self actually the same as my "self?"

Yes. It is the same object.

So If I could have a call stack like this :
...
4 NSObject : CleanUp
3 MyObject : BlowUp //Calls super CleanUP
2 NSObject : CleanUp //Calls Self BlowUP (I would think the super's implementation but calls subclassed one?)
1 MyObject : BlowUp //Calls super CleanUP


Is it true? That is what I'm seeing.

It shouldn't matter what context you invoke the method from. The routine that gets called should be the implementation of that method in the most derived class.
I see. Wow, I don't know how I got this long without noticing that... I'm gonna have to re-read the obj-c guide....
I don't remember seeing this described anywhere that I can remember....


You have to remember that by calling the super method, that does not put you into a 'super mode' where
the class of the object is now considered to be the super class. It is still the same object and any
invocation will to the the 'outermost' class.
Hmm, yes I understand now. I always assumed that it was stratified such that when calling super, inside of that call,
any subsequent calls to "self" within that context would call its own methods in its "level." When returning to "My" subclass,
it would have any calls to self would invoke my customized behavior... I always assumed that subclassing wasn't designed to
alter the mechanics of the super's implementation, but I guess, in some cases it does.


Thanks guys. That cleared a lot of ?s out of my head.

Andre
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Simple but fundamental question (From: email@hidden)
 >Re: Simple but fundamental question (From: Scott Thompson <email@hidden>)

  • Prev by Date: Re: Distributed Objects and Retain
  • Next by Date: Q: Binding to an NSMatrix (of checkboxes)
  • Previous by thread: Re: Simple but fundamental question
  • Next by thread: Re: Simple but fundamental question
  • Index(es):
    • Date
    • Thread