我想知道如何记录从运行下面的方法到按下UIButton的时间 - 有人可能会帮忙吗?
-(void)informToPress
{
textLabel.text = @"Test, press the button";
//begin record and end record on button press
}
谢谢,
答案 0 :(得分:3)
-(void)informToPress
{
textLabel.text = @"Test, press the button";
//begin record and end record on button press
startDate = [[NSDate alloc]init];
}
-(IBAction)stopTime{
stopDate = [[NSDate alloc]init];
//The actual time in seconds
NSLog(@"Time in seconds %f", [stopDate timeIntervalSinceDate:startDate]);
}
或强>
-(IBAction)calculateTime{
//The actual time in seconds just calculated not stored.
NSLog(@"Time in seconds %f", [startDate timeIntervalSinceNow]);
}