• 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: Greg Guerin <email@hidden>
  • Date: Mon, 13 Apr 2009 13:25:16 -0700

Dave DeLong wrote:

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).


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: Dave DeLong <email@hidden>
  • Prev by Date: Re: Need to find out why I get Cocoa error 256 . . . (more info)
  • 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