开发者

Record time from now, to when a button is pressed?

开发者 https://www.devze.com 2023-03-01 15:04 出处:网络
I\'m wondering how to record the time taken from running the method below, to when a UIButton is pressed -- could anyone possibly help?

I'm wondering how to record the time taken from running the method below, to when a UIButton is pressed -- could anyone possibly help?

-(void)inf开发者_如何学编程ormToPress
{
    textLabel.text = @"Test, press the button";
    //begin record and end record on button press
}

Thank you,


-(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]);
}

OR

-(IBAction)calculateTime{
        //The actual time in seconds just calculated not stored.
       NSLog(@"Time in seconds %f", [startDate timeIntervalSinceNow]);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消