【问题标题】:Error trying to set text field text to string尝试将文本字段文本设置为字符串时出错
【发布时间】:2014-07-04 19:22:09
【问题描述】:

我正在尝试将我的文本字段的文本设置为已保存的字符串。我拥有它是全球性的,因为我需要在另一个地方访问它。我收到此错误: Undefined symbols for architecture arm64: "_tailNum", referenced from: -[rvc newPlaneClicked:] in rvc.o "_MM", referenced from: -[rvc newPlaneClicked:] in rvc.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

是什么原因造成的/如何解决?

extern NSString *tailNum;
extern NSString *MM;

- (void)newPlaneClicked:(id)sender {

    UIAlertView *newPlaneAlert = [[UIAlertView alloc]initWithTitle:@"FlightLog Pro" message:@"Enter tail number and make/model:"delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Save", nil];

    newPlaneAlert.delegate = self;
    [newPlaneAlert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

    UITextField *enterNewPlaneTail = [newPlaneAlert textFieldAtIndex:0];
    UITextField *enterNewPlaneMM = [newPlaneAlert textFieldAtIndex:1];

    [enterNewPlaneTail setPlaceholder:@"Click to enter a make/model."];
    [enterNewPlaneMM setPlaceholder:@"Click to enter a plane tail number."];

    [newPlaneAlert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;
    [newPlaneAlert textFieldAtIndex:0].autocorrectionType = YES;

    [newPlaneAlert textFieldAtIndex:1].autocapitalizationType = UITextAutocapitalizationTypeSentences;
    [newPlaneAlert textFieldAtIndex:1].autocorrectionType = YES;
    [newPlaneAlert textFieldAtIndex:1].secureTextEntry = NO;

    [newPlaneAlert show];

    enterNewPlaneTail.text = tailNum;
    enterNewPlaneMM.text = MM;
}

【问题讨论】:

    标签: objective-c error-handling nsstring uitextfield


    【解决方案1】:

    输入这些声明

    extern NSString *tailNum;
    extern NSString *MM;
    

    在您的 .h 文件中并在您的 .m 文件的全局范围内为它们分配一些值:

    NSString *tailNum = @"tailNum";
    NSString *MM      = @"MM";
    

    还可以阅读有关外部变量的更多信息。你可以从Wikipedia开始。 Here 是另一种解释

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 2016-04-29
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      相关资源
      最近更新 更多