问题
i'm developing a iPhone tweak, with the Preferences i created a PreferenceBundle
and in the bundle i need to call a SpringBoard method, but the results is always nothing. Is there a way i can call a SBApplication
method?
i am using objc_getClass to get the class
SBApplication *app =[[objc_getClass("SBApplicationController") sharedInstance] applicationWithDisplayIdentifier:identifier];
when i use that to call the method the result is null.
Is it possible, or some hack i can do. i need to get the iconpath from the SBApplication
.
回答1:
I think it might be easier to use the C SpringBoadServices functions. Go to your Xcode root folder and find the private framework SpringBoardServices
of the iOS simulator platform. Set it as the current directory and run nm
on the executable.
imac-van-ief2:SpringBoardServices.framework ief2$ pwd
/Applications/Xcode 3.2.6/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/PrivateFrameworks/SpringBoardServices.framework
imac-van-ief2:SpringBoardServices.framework ief2$ nm -g SpringBoardServices | grep SBSCopyIcon
00009548 T _SBSCopyIconImagePNGDataForDisplayIdentifier
00009400 T _SBSCopyIconImagePathForDisplayIdentifier
Now you've found the icon path function name, you can call it. Declare it as extern
and you'll be able to do so.
extern NSString *SBSCopyIconImagePathForDisplayIdentifier(NSString *);
myPath = SBSCopyIconImagePathForDisplayIdentifier(@"com.apple.String");
// Do anything you like
[myPath release];
Now, don't forget to link your final executable to the SpringBoardServices
framework and to add /System/Library/PrivateFrameworks
to your framework search path.
来源:https://stackoverflow.com/questions/8757135/ios-preferencebundle