Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get an ivar or property from a NSString

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

like image 435
klefevre Avatar asked Dec 21 '22 12:12

klefevre


2 Answers

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

like image 89
Joshua Weinberg Avatar answered Dec 24 '22 02:12

Joshua Weinberg


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.

like image 27
Caleb Avatar answered Dec 24 '22 01:12

Caleb