I have a textfield (numbers only) and a UILabel which I am adding together with the use of a button. The UILabel displays the answer and the Textfield goes blank on calculation. The calculations and the functionality mentioned, works fine until I start wanting to add numbers more than 10Million. The UILabel displays an answer of -2147483648. The calculation I did to get me to this result was 0 + 1000000000.
I haven't set any limits on the character lengths of either field, so unsure why this is happening.
Here is the code for my calculation:
-(IBAction)addtotal2;{
float x = ([numberTextField.text floatValue]);
float y = ([dtotal.text floatValue]);
dtotaler = x + y;
dtotal.text = [NSString stringWithFormat:@"%d",dtotaler];
numberTextField.text = @"";
NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
[userDefaults setObject:[NSString stringWithFormat:@"%i",dtotaler] forKey:@"saveDtotal"];
[userDefaults synchronize];
Any help would be greatly appreciated. Thanks.