Here is my code:
float timeInterval = 1 / [frameRateTextField floatValue];
recordingTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:@selector(recordingTimerSelector:)
userInfo:nil
repeats:YES];
- (void) recordingTimerSelector:(NSTimer*)timer{
NSXMLElement *timecode = [[NSXMLElement alloc] initWithName:@"timecode"];
[timecode setStringValue:[NSString stringWithFormat:@"%@,%@,%@,%@,%@",[DMXChannelArray objectAtIndex:0], [DMXChannelArray objectAtIndex:1], [DMXChannelArray objectAtIndex:2], [DMXChannelArray objectAtIndex:3], [DMXChannelArray objectAtIndex:4]]];
[root addChild:timecode];
time = time + 1;
[theRecordingTime setStringValue:[NSString stringWithFormat:@"%d", time]];
}
Is this the best way to go about doing this? I’m basically making a “recorder” with a resolution of 30FPS. Is there a way to make it go with the actual time, instead of being a separate entity? It might make it more accurate. Like:
10:40:41.0 - record element
10:40:41.3 - record element
10:40:41.6 - record element
Thanks!
You can get the current number of seconds since the reference date by asking NSDate for it.
Get that time interval when you start your timer, and then every time it fires, and subtract the starting time interval from the current one to get the number of seconds since you started.