我希望在运行时获取指定应用程序的所有类(可能是任何其他应用程序,而不仅仅是应用程序本身),我可以使用它的标识符获取该应用程序的NSBundle
,但是如何使用NSBundle
获取类,或者我可以直接使用应用程序的标识符获取类?我们假设它可能是一个越狱的环境。我试过objc_copyClassNamesForImage
但是失败了,有人有想法吗?
NSBundle * bundle = [NSBundle bundleWithIdentifier:appIdentifier];
NSString * bundlePath = [bundle bundlePath];
NSLog(@"%@", bundlePath);
unsigned int count;
const char **classes;
classes = objc_copyClassNamesForImage([bundlePath UTF8String], &count);
for (int i = 0; i< sizeof(classes)/sizeof(classes[0]); i++){
NSLog(@"class name: %s", classes[i]);
}