在我的THEOS调整中,我挂起了一个类,并成功地调用了它的一个方法。
我的问题是,在我调整的应用程序更新后,方法名称发生了变化。
在旧版本中,有问题的方法接受一个参数(方法:arg1),然后它被更新为接受两个参数(方法:arg1:arg2)。现在,我的代码如下所示
%hook className
- (void)method:arg1 {
//
}
- (void)method:arg1:arg2 {
//
}
%end此设置在新版本上运行良好,但会导致应用程序在旧版本中崩溃。有没有一种方法可以根据捆绑包版本有条件地调用其中一个方法([NSBundle mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"])?
我用过#if和#endif,但没有走远。
非常感谢您的帮助。
发布于 2013-05-10 05:03:52
如果endif是宏编译时,而不是您需要运行时。
我也在学习theos徽标,但我认为你应该在条件下使用%group和%ctor{}。
发布于 2015-12-09 00:46:46
干杯
%group A
%hook className
- (void)method:arg1 {
//
}
%end
%end
%group B
%hook className
- (void)method:arg1:arg2 {
//
}
%end
%end
%ctor{
if([anObject respondsToSelctor:@selector(method:arg1:arg2)]){
%init(B)
}
else{
%init(A)
}
https://stackoverflow.com/questions/16131723
复制相似问题