Quote:
Originally Posted by Bertrand21
Dude, you can make this using other tutorials. Just piece them all together. Or just learn iOS development instead of using "tutorials" to put out crap apps.
|
The thing is that I've got my BMI calculator up and running. But I won't learn if i'm doing it right if I can't check somehow how it should be done. And it's not for AppStore
edit: Hang on and I'll come with my source code soon
fifth try now:
Code:
MainViewController.h
IBOutlet UILabel *bmiLabel;
IBOutlet UITextField *length;
IBOutlet UITextField *weight;
-(IBAction)countBMI;
Code:
MainViewController.m
int bmiInt = 0;
-(IBAction)countBMI{
double weightInt = [weight.text doubleValue];
double lengthInt = [length.text doubleValue];
bmiInt = weightInt/(lengthInt*lengthInt);
NSString *bmi = [NSString stringWithFormat:@"%d", bmiInt];
bmiLabel.text = bmi;
}
edit: how to use double? if I set bmiInt to a double I got wrong data to bmiLabel. (just change %d to %f, right?) - What if i want to round it to .5? like 3.2 = 3.0, 3.3 = 3.5? Trying some with @"%f", (round)bmiInt];