Home > Archive > Objective C > March 2005 > Simple newbie question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Simple newbie question
|
|
|
| How do I get to the Class object for an Instance variable ?
Thing * myThing;
myThing = [[Thing alloc] init];
ie, I can access the name of the Thing class with
[Thing class]
or, from within instance methods of the Thing class I can access "isa"
BUT if I am iterating through an Array and I encounter "myThing", what
message can I send to "myThing" to get to the [Thing class] info ?
Thanks,
Griff
| |
| Christian Brunschen 2005-03-16, 4:06 pm |
| In article <d698d3e7.0502151054.27828fb2@posting.google.com>,
Griff <griffph@aol.com> wrote:
>How do I get to the Class object for an Instance variable ?
>
>Thing * myThing;
>myThing = [[Thing alloc] init];
>
>ie, I can access the name of the Thing class with
>
>[Thing class]
>
>or, from within instance methods of the Thing class I can access "isa"
>
>BUT if I am iterating through an Array and I encounter "myThing", what
>message can I send to "myThing" to get to the [Thing class] info ?
Simple: there is an instance method
- class;
that returns the class object for a given instance. So, you would write
Class someClass = [myThing class];
to retrieve the class of which 'myThing' is an instance.
All of this is documented in the documentation for the NSObject class and
the NSObject protocol.
>Thanks,
Best wishes,
>Griff
// Christian Brunschen
| |
|
| Well, duh!
Yeah, that works..!
Thanks very much Christian :-)
| |
| Christian Brunschen 2005-03-16, 4:06 pm |
| In article <d698d3e7.0502160233.6f92b14a@posting.google.com>,
Griff <griffph@aol.com> wrote:
>Well, duh!
>
>Yeah, that works..!
>
>Thanks very much Christian :-)
You're most welcome :)
Best wishes,
// Christian Brunschen
|
|
|
|
|