another easy one, for you guys I mean:
I need to call a method on an existing object like this:
[object method];
The name of the object however, is different (this code is for a superclass, the children all have different names) each time. So I want to call the object with an NSString like this:
NSString *objectName = @"object";
[objectName method];
I've read about NSClassFromString (I've been looking for hours now), but that doesn't work. Then I get the following error: "no known class method for selector 'method'".
Do you guys know what I'm doing wrong?
Thanks in advance, Frans
NSClassFromStringreturns a class (as its name says), not the contents of a variable. A function that did return a variable would either have to know about all variables everywhere, effectively making all variables global and thus destroying any separation of knowledge, or be able to determine the scope of any caller (e.g., what method of what class the caller is in), and know what variables are visible to that scope. A daunting problem, whose solution is of dubious utility.