我正在尝试通过 userInfo 传递数据以进行 NSTimer 调用。做这个的最好方式是什么?我正在尝试使用 NSDictionary,当我有 Objective-C 对象时这很简单,但是其他数据呢?我想做这样的事情,但不能按原样工作:
- (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];
}