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,595
  • 7
  • 42
  • 71

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
  • 146,289
  • 39
  • 203
  • 257
Joshua Weinberg
  • 28,598
  • 2
  • 97
  • 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
  • 124,013
  • 19
  • 183
  • 272