Simple iPhone tally method question

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-04-26T03:52:29Z Indexed on 2010/04/26 3:53 UTC
Read the original article Hit count: 182

Filed under:

Just trying to create a simple method that counts up 1 on the tally when the button is pressed. My knowledge is extremely limited and I am pretty sure that my problem is somewhere in the method implementation:

-(IBAction) updateTally:(id) sender {
    NSString *text;
    int total = 0;
    total = total + 1;
    text=[[NSString alloc] initWithFormat: @"%i", total];
    lblTally.text = text;
}

I have done the necessary interface declarations for the lblTally UILabel and the updateTally method. I suspect that there is some sort of an NSString/int/%i/%@ mixup that I am making but I'm not sure how to fix it. When I run the program as it currently is it displays a 0 in the lblTally label field on the iphone. When I press the button it then displays a 1 in that field. However, if I continue to press the button - nothing happens.

© Stack Overflow or respective owner

Related posts about iphone