好比:對象
NSMutableDictionary *dic = [[NUMutableDictionary alloc]init];get
[dic setValue:@」haha」 forKey:@」test」]it
[NSTimer scheduledTimerWithTimeIntervatal:2.0 target:self selector:io
@selecrtor(onTimer:) userInfo:dic repeats:NO];table
關於上述調用onTimer:方法時怎麼傳遞參數,可能在這裏會有一個疑問,我只知道方法名,我怎麼知道要傳遞什麼類型的參數。其實很簡單,傳遞的參數爲NSTimer的對象,從NSTimer的對象的對象中能夠拿到userInfo中的dic,從而取出dic中的數據。test
因此,onTimer:方法的實現必須以下(參數必須爲onTimer類型):select
-(void)onTimer:(NSTimer *)timer{方法
.............................im
}數據