开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜