我正在尝试使用 MSHookIvar 获取 ivar,但出现此错误:“'MSHookIvar' 未在此范围内声明”。我试图在我的 iphone 和 mac 中编译它,但两者都说我有这个错误。谢谢
这是我的代码:
#import "substrate.h"
%hook SBAwayController
- (void)_unlockWithSound:(BOOL)arg1 unlockSource:(int)arg2 isAutoUnlock:(BOOL)arg3 bypassPinLock:(BOOL)arg4{
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(21, 80, 100, 35);
[myButton setTitle:@"My Button" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(myButtonPressed) forControlEvents:UIControlEventTouchUpInside];
SBUIController *ui = MSHookIvar<id>(self, "_uiController");
[[ui window ] addSubview:myButton];
%orig(arg1,arg2,arg3,arg4);
}
%end
%hook SBUIController
- (id)window{
return %orig;
}
%end