有沒有辦法編寫代碼而不是將選擇器設置爲在NSTimer中調用的方法? 如果我想在5秒後打印hello world,我可以這樣做。在類似NSTimers中編寫代碼而不是選擇器?
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(helloWorld:) userInfo:nil repeats:NO];
,並在同一行,因爲我創造一個有此功能
-(void)helloWorld:(NSTimer*)aTimer {
NSLog(@"Hello World!");
}
但不是對你有充分的計時器writeing功能是可以添加的NSLog(@的「Hello World!」)定時器?
複製http://stackoverflow.com/questions/4007023/blocks-instead-of-performselectorwithobjectafterdelay你可能會找到合適的答案。 – hotpaw2 2011-05-26 00:15:52