Re: Dynamically getting the type of ivars
Re: Dynamically getting the type of ivars
- Subject: Re: Dynamically getting the type of ivars
- From: Dave DeLong <email@hidden>
- Date: Mon, 13 Apr 2009 13:09:59 -0600
I don't think that'll work. Here's what I'm doing:
unsigned int numIvars = 0;
Ivar * ivars = class_copyIvarList(aClass, &numIvars);
for (int i = 0; i < numIvars; i++) {
Ivar thisIvar = ivars[i];
Class ivarClass = somethingToGetTheIvarClassIfItsAnObject(thisIvar);
}
I can check to see if an Ivar is an object by checking to see if the
first character of ivar_getTypeEncoding(thisIvar) is the '@' symbol
(this, I believe, is documented to be true). However, since all I
have is an Ivar pointer, I'm not sure how I can get the static type of
the Ivar (if it's an object).
Thanks,
Dave
On Apr 13, 2009, at 12:12 PM, Nick Zitzmann wrote:
On Apr 13, 2009, at 11:10 AM, Dave DeLong wrote:
Can I reliably pull out that stuff in between the quotes to get the
class of the Ivar? (This seems sketchy to me...) Is this the best
way to do this?
No.
If not, what do I need to do to get the Ivar's type?
Just use the -class and +class methods. If you need to check to see
whether an object is, or is a subclass of, a certain class, then use
-isMemberOfClass: and -isKindOfClass: respectively.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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