iOS PreferenceBundle

筅森魡賤 提交于 2019-12-08 12:02:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!