ios - How to add these two values together in objective c -
ios - How to add these two values together in objective c -
i'm stuck adding these values together. both come .plist. both numbers. want add together values , display result string in label.
nsinteger calories = [[self.main objectforkey:@"calories"] integervalue]; nsinteger calories2 = [[self.apps objectforkey:@"calories"] integervalue];
i want go
nsstring *totalcalories = calories + calories2; self.calorielabel.text = totalcalories;
but not work. i'm new , sense i'm missing little , obvious.
any insight?
you’re there far add-on itself:
nsinteger totalcalories = calories + calories2;
now need convert number string, can this:
nsstring *totalcaloriestext = [nsstring stringwithformat:@"%d", totalcalories];
the problem trying treat integer look (calories + calories2
) string. valid thing in programming languages, in objective-c have explicit such conversions.
ios objective-c iphone
Comments
Post a Comment