我正在使用theos为iOS编写我的第一次修改,而且我被困在了optimization.As中,我可以看到,dylib每次都会检查(每秒钟一次?)([设置对象为file:@“settings”boolValue])和“[设置对象为file:@”SomethingHere“boolValue]”。
可以吗?有优化的建议吗?这是我的调整:
%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发布于 2014-02-12 07:05:21
如果在首选项面板中使用PreferenceLoader,则可以将值保存在全局变量中,并使用达尔文通知来监视首选项的更改。您可以在开放源码调整中找到许多示例,例如我的一个示例:
https://github.com/Qusic/MailtoOpener/blob/master/Tweak.mm#L192
https://stackoverflow.com/questions/21652803
复制相似问题