//I am creating a dictionary object that I can pass to my selector method.
NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", @"key3", nil];
NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", nil];
NSDictionary *myDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[NSTimer scheduledTimerWithTimeIn
//The fireTimer() is the selector method I setup above
- (void) fireTimer:(NSTimer*)theTimer {
for (id key in [theTimer userInfo]) {
NSLog(@"key: %@, value: %@", key, [[theTimer userInfo] objectForKey:key]);
}
//kill the timer
[theTimer invalidate];
theTimer = nil;
}
//here is a similar example but with using an NSNumber
NSNumber *myInt = [NSNumber numberWithInt:4];
[NSTimer scheduledTimerWithTimeIn
- (void) fireTimer:(NSTimer*)theTimer {
NSLog(@" %i ", [[theTimer userInfo] integerValue]);
[theTimer invalidate];
theTimer = nil;
}