按照这里的解释:
https://github.com/nst/iOS-Runtime-Headers
我正在尝试在捆绑 TelephonyUtilities.framework 中获取 TUPhoneLogger 的类。但是,调试器总是显示"error: unknown class"。
我有两种不同的方法:
第一种方法:
NSBundle* b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/TelephonyUtilities.framework"];
BOOL success = [b load];
NSLog(@"%@", [b definedClasses_dd]);
注意:我创建了一个 @interface NSBundle (DDAdditions) 扩展:
- (NSArray *)definedClasses_dd {
NSMutableArray *array = [NSMutableArray array];
int numberOfClasses = objc_getClassList(NULL, 0);
Class *classes = calloc(sizeof(Class), numberOfClasses);
numberOfClasses = objc_getClassList(classes, numberOfClasses);
for (int i = 0; i < numberOfClasses; ++i) {
Class c = classes[i];
if ([NSBundle bundleForClass:c] == self) {
[array addObject:c];
const char* nameOfClass = class_getName(c);
NSString* classString = [NSString stringWithUTF8String:nameOfClass];
if([classString isEqualToString:@"TUPhoneLogger"]) {
NSLog(@"Found it! TUPhoneLogger");
id test= [[c alloc] init];
NSLog(@"test: %@", test);
}
}
}
free(classes);
第二种方法:
NSBundle* b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/TelephonyUtilities.framework"];
Class telephonyClass = [b classNamed:@"TUPhoneLogger"];
id test= [[telephonyClass alloc] init];
NSLog(@"%@", test);
在调试器中: