Adding two textfields

Discussion in 'iOS Programming' started by tazboy, Apr 6, 2010.

  1. tazboy macrumors newbie

    Joined:
    Apr 6, 2010
    #1
    I've searched here but I was not able to find a solution.

    I'm trying this:
    Code:
    NSInteger *sum;
    @property (assign) NSInteger *sum;
    @synthesize sum;
    Code:
    sum = [First1Total.text integerValue] + [First2.text integerValue];
    First2Total.text = [sum stringValue];
    I'm obviously not doing this correctly. Does anyone have any ideas on how to get this to work?

    Thanks for any help.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    NSInteger is not a class but a typedef. No need for the *.
     
  3. tazboy thread starter macrumors newbie

    Joined:
    Apr 6, 2010
    #3
    Thanks for the help. I also had to change something else. Here is my code that works:

    Code:
    sum = [First1Total.text integerValue] + [First2.text integerValue];
    First2Total.text = [NSString stringWithFormat:@"%d", sum];
     

Share This Page