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 14:41:54 -0600
Again, I don't think that's what I'm looking for.
For example, let's say I create a class called "Bogus", that has one
ivar, a pointer to another Bogus object. Let's say I get the Ivar
pointer via the class_copyIvarList function, and then print the
typeEncoding of the Bogus ivar, like this:
NSLog(@"Bogus ivar: %s", ivar_getTypeEncoding(BogusIvar));
This prints out:
Bogus ivar: @"Bogus"
However, if I simply do:
NSLog(@"Bogus: %s", @encode(Bogus));
Then I get:
Bogus: {Bogus=#@}
So I got thinking that wasn't what I wanted, so I did:
NSLog(@"Bogus pointer: %s", @encode(Bogus *));
This prints:
Bogus pointer: @
Still not what I'm looking for. I have an Ivar pointer, and I want to
get its static type (if it has one).
Dave
On Apr 13, 2009, at 2:25 PM, Greg Guerin wrote:
Call ivar_getTypeEncoding(Ivar) to get its type-encoding string. To
decipher the type-encoding string, see this:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
In particular, note:
"Objects are treated like structures."
-- GG
_______________________________________________
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