我听说theos中有一个%group特性。根据我对此的理解,我猜这是为了在条件设置为真时,或者当您想要轻松地启用或禁用它而不是使用if()时,应用大量的钩子。我说的是真的吗?如果满足某个条件,我如何使用此功能?请帮助我,因为我真的需要这个功能,因为我有很多的of和其他在我的代码中,它将更容易只使用%group而不是所有这些!任何建议都是非常感谢的!
发布于 2012-09-30 20:46:37
我找到了答案;
%hook之前使用%group thegroupname,但请记住在后面放两个%end。%ctor中,您可以在需要时调用%init(thegroupname);。希望这对某些人有帮助!顺便说一句,%init()函数可以在任何地方使用,甚至可以在%hook中使用。
%group MessagesApp
%hook CLASS_TO_HOOK
- (id)FUNC_TO_HOOK {
return %orig;
}
%end
%end //Don't forget your second end.
%ctor {
if (TRUE) {
%init(MessagesApp);
}
}发布于 2015-10-29 22:58:20
添加答案以进一步澄清,使用如下所示:
%group iOS8
%hook IOS8_SPECIFIC_CLASS
// your code here
%end // end hook
%end // end group ios8
%group iOS9
%hook IOS9_SPECIFIC_CLASS
// your code here
%end // end hook
%end // end group ios9
%ctor {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) {
%init(iOS9);
} else {
%init(iOS8);
}
}https://stackoverflow.com/questions/12508442
复制相似问题