Re: get superclass instance
Re: get superclass instance
- Subject: Re: get superclass instance
- From: Thomas Lachand-Robert <email@hidden>
- Date: Mon, 7 Mar 2005 18:49:44 +0100
Le 7 mars 05, à 18:35, Agent M a écrit :
I would like to set the target of an NSInvocation to be the
superclass of the current object, however
[invocation setTarget:super];
doesn't work because super is not an id and I can't figure out what
kind of structure it is. (It seems to have a class member, but not
receiver, so it is not an objc_super struct.)
super is not an object, it is a keyword of the Objective-C language.
But it is some sort of struct as well as a keyword- I just don't know
which one. "super" clearly isn't orthogonal to "self", which is and
id.
No it is not a struct it is a KEYWORD. Any call like [super
doSomething] is translated by the compiler to a call to
objc_msgSendSuper, see
http://developer.apple.com/documentation/Cocoa/Reference/
ObjCRuntimeRef/index.html
Outside of this context, "super" has no meaning. The same thing happens
for the name of any class, like NSObject. You can write [NSObject
doSomething], but you need to write
[self doSomethingWithClass:[NSObject class]]
More generally, how can I get an id which points to the superclass
instance (not the meta-class), given "self"?
Did you try [theobject superclass] ?
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Protocols/NSObject.html#//apple_ref/doc/uid/20000052/
BBCDIACA
-superclass returns the meta-class which is useless in this situation.
I need an id which represents the superclass. I have a feeling that
the objc-class structure doesn't support such a notion. Oh well.
No this returns the super class, so a call to
[invocation setTarget:[myobject superclass]];
will work for your case. Just try it.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet à la chose. >> Molière, Tartuffe.
_______________________________________________
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