ulquiorra
Sep 14, 2009, 03:01 AM
Hello all ,
I'd like to create some sort of timer that will take the time between firing different kind of functions but I'm having no such luck so far. I assumed I should use the NSDate object and I've done this so far.
I've created several functions
-(void)startTime:(id)sender
{
starttime = [NSDate date];
NSLog(@"show me the starttime %f", starttime);
}
-(void)endTime:(id)sender
{
endtime = [NSDate date];
NSLog(@"show me the endtime %f", endtime);
}
-(void)timeInterval:(id)sender
{
NSTimeInterval interval = [ starttime timeIntervalSinceDate:endtime];
NSLog(@"let me see the timeinterval between now and then %f", interval);
}
For instance when I press a playbutton which will play a movie
I will place the starttime function
-(void)playMovie:(id)sender
{
[self startTime:(id)sender];
[self callMovie];
}
And when I press a stopbutton for the movie the stopfunction will be called as will the timeInterval function
-(IBAction)stopMovie:(id)sender
{
[self stopTime:(id)sender];
[self myMovie];
[self timeInterval:(id)sender];
}
However it doesn't seem to work. If i press the stopbutton after 3 seconds I would assume my
function timeInterval would give an output of 3 seconds. Unfortunately to no avail.
Anyone knows what's going on and what I'm doing wrong?
I'd like to create some sort of timer that will take the time between firing different kind of functions but I'm having no such luck so far. I assumed I should use the NSDate object and I've done this so far.
I've created several functions
-(void)startTime:(id)sender
{
starttime = [NSDate date];
NSLog(@"show me the starttime %f", starttime);
}
-(void)endTime:(id)sender
{
endtime = [NSDate date];
NSLog(@"show me the endtime %f", endtime);
}
-(void)timeInterval:(id)sender
{
NSTimeInterval interval = [ starttime timeIntervalSinceDate:endtime];
NSLog(@"let me see the timeinterval between now and then %f", interval);
}
For instance when I press a playbutton which will play a movie
I will place the starttime function
-(void)playMovie:(id)sender
{
[self startTime:(id)sender];
[self callMovie];
}
And when I press a stopbutton for the movie the stopfunction will be called as will the timeInterval function
-(IBAction)stopMovie:(id)sender
{
[self stopTime:(id)sender];
[self myMovie];
[self timeInterval:(id)sender];
}
However it doesn't seem to work. If i press the stopbutton after 3 seconds I would assume my
function timeInterval would give an output of 3 seconds. Unfortunately to no avail.
Anyone knows what's going on and what I'm doing wrong?
