我想通過userInfo傳遞數據進行NSTimer調用。做這個的最好方式是什麼?我想使用NSDictionary,當我有Objective-C對象時,這很簡單,但其他數據呢?我想要做這樣的事情,不作爲就是工作:通過NSTimer傳遞數據UserInfo
- (void)play:(SystemSoundID)sound target:(id)target callbackSelector:(SEL)selector
{
NSLog(@"pause ipod");
[iPodController pause];
theSound = sound;
NSMutableDictionary *cb = [[NSMutableDictionary alloc] init];
[cb setObject:(id)&sound forKey:@"sound"];
[cb setObject:target forKey:@"target"];
[cb setObject:(id)&selector forKey:@"selector"];
[NSTimer scheduledTimerWithTimeInterval:0
target:self
selector:@selector(notifyPause1:)
userInfo:(id)cb
repeats:NO];
}
當你進入'-notifyPause1:'時'cb' nil: – 2010-04-16 09:34:48