When I'm creating an NSThread I pass it a number that I want the process to be aware of. I can understand how to set the number but I cannot figure out how to read the number from the thread selector method so that I can then pass it to a timer.
How do you do it?
-(void) setthread
{
//passing the number to the selector here fine
NSThread* timerThread = [[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:[NSNumber numberWithInt:index]];/
[timerThread setThreadPriority:0.5];
[timerThread start]; //start the thread
}
// don't get how to read the value passed to this selector
-(void) startTimerThread
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
[[NSTimer scheduledTimerWithTimeInterval: 0.1
target: self
selector: @selector(timerTick:)
userInfo: thenumberhere
repeats: YES] retain];
[runLoop run];
[pool release];
}
- (void)timerTick:(NSTimer *)timer
{
//code
}