So I’m trying to input a time in minutes automatically into my equation when (IBAction)calculate: (id)sender is triggered. Right now I have the time going in as a UITextField (IBOutlet UITextField *amountOfInt) and I would like a time in minutes to replace that automatically when calculate is pressed. When the button is pressed I don’t want the difference in time, I need to get the total time since it was initialized to go into the equation and output into IBOutlet UILabel *bOOK every time it is pressed.
My.h is:
IBOutlet UITextField *weight;
IBOutlet UITextField *amountOfInt;
IBOutlet UILabel *bOOK;
IBOutlet UILabel *numberOfDrops;
}
-(IBAction)calculate:(id)sender;
My .m is:
-(IBAction)calculate: (id)sender {
static int myInt = 0;
myInt++;
float floatbAC = (((myInt * .6) / ([weight.text floatValue] * .57)) - (.5678 * [amountOfTime.text floatValue]);
NSString *stringbOOK = [[NSString alloc] initWithFormat:@"%1.2f",floatbOOK ];
NSString *string = [NSString stringWithFormat:@"%d", myInt];
[numberOfDrops setText:string];
bOOK.text = stringbOOK;
[stringbOOK release];
Not sure you what you are referring to when you say it is initialised, but you can create a NSDate object when your ‘it’ gets initialised, like
and then when you button is pressed use the timeIntervalSinceDate method
This might give you a negative result, can’t remember which is subtracted from which, you will just have to negate the result or swap the dates around