0

これが私のコードです:

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

これはこれを行うための最良の方法ですか?私は基本的に30FPSの解像度の「レコーダー」を作っています。個別のエンティティではなく、実際の時間に合わせる方法はありますか?それはそれをより正確にするかもしれません。好き:

10:40:41.0 - record element
10:40:41.3 - record element
10:40:41.6 - record element

ありがとう!

4

1 に答える 1

0

NSDateに問い合わせることで、参照日からの現在の秒数を取得できます。

タイマーを開始するとき、およびタイマーが起動するたびにその時間間隔を取得し、現在の時間間隔から開始時間間隔を引いて、開始してからの秒数を取得します。

于 2013-01-19T03:12:03.333 に答える