iPhone simulator app crashes when appending a string

Posted by Franklyn Weber on Stack Overflow See other posts from Stack Overflow or by Franklyn Weber
Published on 2010-05-03T22:22:26Z Indexed on 2010/05/03 22:28 UTC
Read the original article Hit count: 227

Filed under:
|
|

Hi,

I'm a complete novice, so I'm probably missing something really easy, but I can't get my string appending to work. I add the 3rd character to typedDigit & it crashes - the method is called fine and typedDigit will get to 2 characters long. I think everything is declared properly in the header file. Code is -

-(IBAction)digitPressed:(UIButton *)sender {

    NSString *digit = [[sender titleLabel] text]; // in this case, "0" - "9"

    if (userIsInMiddleOfTyping) {   // typedDigit is already at least 1 character long
        typedDigit = [typedDigit stringByAppendingString:digit];
    } else {                        // first character of typedDigit
        typedDigit = digit;
        userIsInMiddleOfTyping = YES;
    }

}

Many thanks for any help!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nsstring