NSTimerでメソッドを定時実行

logTimerというメソッドを1秒間隔で実行している。

SEL sel = @selector(logTimer);
NSMethodSignature *signature = [self methodSignatureForSelector:sel];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
	
[invocation setTarget:self];
[invocation setSelector:sel];
	
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 invocation:invocation repeats:YES];

NSMethodSignatureとNSInvocationについてはこちら

iPhone デベロッパーズ クックブック
iPhone デベロッパーズ クックブック株式会社クイープ

ソフトバンククリエイティブ 2009-02-12
売り上げランキング : 67575

おすすめ平均 star
star初心者にはおすすめできない
starなぜだろう?評判悪いですね
star翻訳は?だが、内容はやはりよい

Amazonで詳しく見る
by G-Tools