I am trying to call a method from another class which is in another source file.
Example:
- I have a file named
Source1.h/Source1.m(both are objective C class files) - I have another file names
Source2.h/Source2.m(both are objective C class files) Source1contains 2 methods eg:method1andmethod2.- From
Source2file, I need to call themethod1fromsource1file.
I know how to do that in objective C. But in my source2 file, the method names in Source1 will be retrieved dynamically. I am not going to hard code it some thing similar to this.
Source1 *a = [[Source1 alloc]init];
[a method1];
The method1 text will taken from a text file. I can use Selector to invoke a method from same class. But I can’t use selector to call method from another class.
Please help to solve this issue….
Many Thanks……
This answer seems to be relevant: How can I dynamically create a selector at runtime with Objective-C?
Basically you can use NSSelectorFromString to make a selector from an UTF8 string in an NSString.