我正在尝试在iOS 9.1下使用BatteryCenter
和私有框架并借助nst's iOS Runtime Headers。这是出于研究目的,并不会让它进入AppStore。私有iOS框架返回NULL
这里有各自的代码:
- (void)batteryCenter {
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/BatteryCenter.framework"];
BOOL success = [bundle load];
if(success) {
Class BCBatteryDevice = NSClassFromString(@"BCBatteryDevice");
id si = [[BCBatteryDevice alloc] init];
NSLog(@"Charging: %@", [si valueForKey:@"charging"]);
}
}
- (void)commonUtilities {
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/CommonUtilities.framework"];
BOOL success = [bundle load];
if(success) {
Class CommonUtilities = NSClassFromString(@"CUTWiFiManager");
id si = [CommonUtilities valueForKey:@"sharedInstance"];
NSLog(@"Is Wi-Fi Enabled: %@", [si valueForKey:@"isWiFiEnabled"]);
NSLog(@"Wi-Fi Scaled RSSI: %@", [si valueForKey:@"wiFiScaledRSSI"]);
NSLog(@"Wi-Fi Scaled RSSI: %@", [si valueForKey:@"lastWiFiPowerInfo"]);
}
}
虽然我得到的类回去,他们所有的尊重数值是NULL这是奇怪的,因为有些必须是真实的,例如我已连接到Wi-Fi,因此isWiFiEnabled
应该是YES
。
错过了什么,我的代码没有返回什么期望?它是否需要权利?如果是这样的话?