Reputation: 627
I got a .framework file, and I use class-dump to know there is a class named ABC
inside and don't expose anything, and ABC
have a useful method for me, so I wonder know can I call ABC's
method dynamic by Objective-C runtime.
Wait for your help!
Upvotes: 0
Views: 634
Reputation: 69459
To create an instance of class if by it's name use NSClassFromString
:
Class myPrivateClass = NSClassFromString(@"MyPrivateClass");
myPrivateClass *myPrivateObj = [myPrivateClass new];
Now that you have the instance of the class call the select, to make it easier you can cast the instance to NSObject
[(NSObject *)myPrivateClass performSelector:@selector(description) withObject:nil];
Or the class method:
[myPrivateClass performSelector:@selector(description)];
Here I'm calling description
on the instance and class.
Upvotes: 2