简体   繁体   中英

use of undeclared identifier 'alertView'

I'm using theos to build my tweak. And this happened: Tweak.x:18:10: error: use of undeclared identifier 'alertView'
Here's my code

#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

Please help, thanks very much.

The closing brace for handleStatusBarTapWithEvent is in the wrong place. You've got alertView:clickedButtonAtIndex: defined inside handleStatusBarTapWithEvent , which is not correct, and the compiler is confused by that. Move the closing brace for handleStatusBarTapWithEvent before alertView:clickedButtonAtIndex:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM