Reputation: 4726
I'm using nst's iOS Runtime Headers to get access to the CoreTelephony.framework.
Here is his sample code:
NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/FTServices.framework"];
BOOL success = [b load];
Class FTDeviceSupport = NSClassFromString(@"FTDeviceSupport");
id si = [FTDeviceSupport valueForKey:@"sharedInstance"];
NSLog(@"-- %@", [si valueForKey:@"deviceColor"]);
His sample usage code gives me access to FTServices.framework but when I apply the same logic, it fails since CoreTelephony does not house a class method named sharedInstance().
Should I declare and implement that myself or is there another way?
Thanks.
EDIT:
My attempt:
NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/Frameworks/CoreTelephony.framework"];
BOOL success = [b load];
Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
id si = [CTTelephonyNetworkInfo valueForKey:@"sharedInstance"]; // fails here
NSLog(@"-- %@", [si valueForKey:@"cachedSignalStrength"]);
Upvotes: 1
Views: 936
Reputation: 2910
The problem is that CTTelephonyNetworkInfo
actually has no property sharedInstance
. Referred from here, CTTelephonyNetworkInfo
is a data structure designed to house the relevant info, and can be accessed (constructed) directly through the standard [[CTTelephonyNetworkInfo alloc] init]
(referred from here).
So for your case:
NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/Frameworks/CoreTelephony.framework"];
BOOL success = [b load];
Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
id si = [[CTTelephonyNetworkInfo alloc] init];
NSLog(@"-- %@", [si valueForKey:@"cachedSignalStrength"]);
Make sure you test on an actual phone though! Simulators have no such information stored.
Edits:
If you want to call methods on a generated class, use performSelector:
or NSInvocation
class.
Upvotes: 3