首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >优化技巧(THEOS)

优化技巧(THEOS)
EN

Stack Overflow用户
提问于 2014-02-08 22:52:53
回答 1查看 335关注 0票数 0

我正在使用theos为iOS编写我的第一次修改,而且我被困在了optimization.As中,我可以看到,dylib每次都会检查(每秒钟一次?)([设置对象为file:@“settings”boolValue])和“[设置对象为file:@”SomethingHere“boolValue]”。

可以吗?有优化的建议吗?这是我的调整:

代码语言:javascript
复制
%hook Something
- (void)somethingheree:(_Bool)arg1 withNumberOfDevices:(int)arg2
{
    NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithContentsOfFile:
                                [NSString stringWithFormat:@"%@/Library/Preferences/%@", NSHomeDirectory(), @"com.yourcompany.mytweak.plist"]];

       if([[settings objectForKey:@"something"] boolValue]) {
        %orig(YES,100);
    }
    else %orig;

}
%end

%hook somethinganother
- (void)somethinghere:(_Bool)arg1
{
    NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithContentsOfFile:
                                [NSString stringWithFormat:@"%@/Library/Preferences/%@", NSHomeDirectory(), @"com.yourcompany.mytweak.plist"]];
       if([[settings objectForKey:@"SomethingHere"] boolValue]) {
        %orig(NO);
    } else %orig;
}
%end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-12 07:05:21

如果在首选项面板中使用PreferenceLoader,则可以将值保存在全局变量中,并使用达尔文通知来监视首选项的更改。您可以在开放源码调整中找到许多示例,例如我的一个示例:

https://github.com/Qusic/MailtoOpener/blob/master/Tweak.mm#L192

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21652803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档