2012-01-12 5 views
-2

どのように私はCocoaで何らかのアクションをループできますか?たとえば、textFieldの乱数が1秒ごとに変更されるようにしたいとします。Cocoaのループアクション

+0

Xcodeは単なるIDEです。Objective-C/Cocoaを意味するのでしょうか? –

答えて

3

例:

-(void)awakeFromNib { 

    [NSTimer scheduledTimerWithTimeInterval:1 
           target:self 
           selector:@selector(changeTextFieldsInt:) 
           userInfo:nil 
           repeats:YES]; 
} 

- (void)changeTextFieldsInt:(NSTimer *)time { 
    [textField setIntValue:rand()]; 
} 

はIBoutlet TextFieldを忘れないでください。