Passing Data thru NSTimer UserInfo

Posted by zorro2b on Stack Overflow See other posts from Stack Overflow or by zorro2b
Published on 2010-04-16T09:30:59Z Indexed on 2010/04/16 9:33 UTC
Read the original article Hit count: 267

Filed under:
|
|

I a trying to pass data thru userInfo for an NSTimer call. What is the best way to do this? I am trying to use an NSDictionary, this is simple enough when I have objective c objects, but what about other data? I want to do something like this, which doesn't work as is:


- (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];
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nstimer