我想通过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