【问题标题】:Tips for optimization (THEOS)优化技巧 (THEOS)
【发布时间】:2014-02-08 22:52:53
【问题描述】:

我正在使用 theos 为 iOS 编写我的第一个调整,但我一直在优化。正如我所见,dylib 每次都会检查(每秒?)“([[settings objectForKey:@"something"] boolValue]) " 和 "[[settings objectForKey:@"SomethingHere"] boolValue]" 在 plist 文件中。

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

%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

【问题讨论】:

    标签: ios objective-c xcode jailbreak theos


    【解决方案1】:

    如果您将 PreferenceLoader 用于您的首选项面板,您可以将值保存在全局变量中,并使用 darwin 通知来监控首选项的变化。您可以在开源调整中找到很多示例,例如我的一个:

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

    【讨论】:

      猜你喜欢
      • 2010-11-10
      • 1970-01-01
      • 2011-04-30
      • 2012-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多