优化提示 (THEOS)



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

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

%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

如果您将首选项加载器用于首选项面板,则可以将值保存在全局变量中,并使用 darwin 通知来监视首选项的更改。你可以在开源调整中找到很多例子,比如我的一个:

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

最新更新