简体   繁体   中英

Using stringByAppendingString to add character to existing string in Xcode/objective-C

I am trying to add the character "1" to the existing value of a textbox "output" in Xcode objective-C.

I am trying to use the "stringByAppendingString" function, and have looked at some examples and can't seem to get this to work.

Is my syntax just wrong?

- (IBAction)pressOne:(id)sender {
    NSString *str1 = output.text;

    output.text = [str1  stringByAppendingString:[@"1"];

}

摆脱@符号前的迷路括号:

output.text = [str1 stringByAppendingString:@"1"];

试试[str1 stringByAppendingString:@"1"];

删除括号:

output.text = [str1  stringByAppendingString:@"1"];

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