addTimer:forMode:
実行ループオブジェクトにタイマーを加えます
-(void)addTimer:(NSTimer *)aTimer: forMode:(NSString *)mode:
解説
実行ループオブジェクト(RunLoop)にタイマーを加えます。
入力モードからタイマーを削除するにはタイマーにinvalidateメッセージを送信します。
【mode】
● NSModalPanelRunLoopMode
● NSEventTrackingRunLoopMode
返り値
( void )
なし
引数
( NSTimer * )aTimer
タイマー
( NSString * )mode
モード?
フレームワーク
Foundation
クラス
NSRunLoop
Instance Methods
使用可能
10.0
参照
例文
#import "MyObject.h" @implementation MyObject NSTimer *timer; - (IBAction)myAction:(id)sender { timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerControl) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; } - (IBAction)fire:(id)sender { } - (IBAction)stop:(id)sender { } -(void)timerControl{ int i; i = [myOutlet intValue]+1; [myOutlet setIntValue:i]; [myOutlet display]; } @end