samedi 27 juin 2015

How to get all the classes of an application specified with identifier in iOS?

I want to get all the classes of a specified application (maybe any other apps, not only the app itself), I can get the NSBundle of that application with it's identifier, but how can I get the classes with the NSBundle, or can I get the classes directly with the application's identifier? We assume it could be a jailbroken environment.I tryied objc_copyClassNamesForImage but failed, does any one have ideas? Any help will be appreciated!

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]);
}

Aucun commentaire:

Enregistrer un commentaire