4

Can we get an ivar or a property from a NSString like we can get a class from a NSString with the function NSClassFromNSString() ?

klefevre
  • 8,346
  • 7
  • 38
  • 69

2 Answers2

8

For any properties you can just use [object valueForKey:myString] and it'll be done. This can also find ivars in certain situations.

Abizern
  • 138,728
  • 38
  • 201
  • 254
Joshua Weinberg
  • 28,440
  • 2
  • 96
  • 90
  • 1
    I’ve posted an answer to [this question](http://stackoverflow.com/q/5784875/557219) showing how to obtain ivars using the Objective-C runtime. –  Jun 09 '11 at 00:04
3

There are a number of functions in the Objective-C Runtime that let you get the list of ivars, properties, and methods associated with a given class, and then to get information about individual ivars, properties, and methods. Take a look at the Objective-C Runtime Reference.

Caleb
  • 122,179
  • 19
  • 178
  • 268