4

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"];

}
2
  • 2
    What's your problem? The code doesn't compile? Do you have an error when running the app? Or is the text box not updated? Commented Mar 17, 2012 at 17:16
  • your problem is related to NSString class so read first documentation of NSString. Commented Mar 17, 2012 at 19:26

3 Answers 3

4

Get rid of the stray bracket before the @ symbol:

output.text = [str1 stringByAppendingString:@"1"];
Sign up to request clarification or add additional context in comments.

Comments

1

try [str1 stringByAppendingString:@"1"];

Comments

0

Remove the brackets:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.