• 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: Dynamically getting the type of ivars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Dynamically getting the type of ivars
      • From: Greg Parker <email@hidden>
References: 
 >Re: Dynamically getting the type of ivars (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Dynamically getting the type of ivars
  • Next by Date: Re: Dynamically getting the type of ivars
  • Previous by thread: Re: Dynamically getting the type of ivars
  • Next by thread: Re: Dynamically getting the type of ivars
  • Index(es):
    • Date
    • Thread