问题描述
我正在使用theos进行调整。发生了这种情况: Tweak.x:18:10:错误:使用了未声明的标识符'alertView'
这是我的代码
#import "/Library/Developer/CommandLinetools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSTask.h"
%hook SBStatusBarManager
UITextField *textField;
- (void)handleStatusBarTapWithEvent:(id)arg1
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"message"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK",nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
textField.placeholder = @"123";
[alert show];
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInterger)buttonIndex
{
if (buttonIndex == 1)
{
UITextField *command = alert.textField;
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/bin/bash";
task.arguments = @[command];
[task launch];
UIAlertView *alert = [[UIAlertView alloc] init]
initWithTitle:@"123"
message:nil delegate:self
cancelButtonTitle:@"123" otherButtonTitles:nil];
}
}
}
%end
请帮助,非常感谢。
解决方法
handleStatusBarTapWithEvent
的右括号放在错误的位置。您在内部{em> {em> alertView:clickedButtonAtIndex:
中定义了handleStatusBarTapWithEvent
,这是不正确的,编译器对此感到困惑。将handleStatusBarTapWithEvent
的右括号移到alertView:clickedButtonAtIndex: