NSThread를 만들 때 프로세스에 알리고 싶은 번호를 전달합니다. 숫자를 설정하는 방법을 이해할 수 있지만 스레드 선택기 메서드에서 숫자를 읽는 방법을 알아낼 수 없으므로 타이머에 전달할 수 있습니다.개체를 NSThread 선택기로 전달
어떻게 하시겠습니까?
-(void) setthread
{
// 여기에 고급 선택기에 수를 통과
NSThread* timerThread = [[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:[NSNumber numberWithInt:index]];/
[timerThread setThreadPriority:0.5];
[timerThread start]; //start the thread
}
//
-(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
}
이 답변은 비슷한 문제에 대한 저를 도왔습니다. +1;) – craig1231