看板 MacDev 關於我們 聯絡資訊
小弟有一段code如下, 請各位先進給我一點意見: - (void)RunVideoStream:(id)destView { videoStream = [[myStream alloc] init]; videoStream.channel = 0; xxx streamThread = [[NSThread alloc] initWithTarget:self selector:@selector(StreamStart) object:nil]; [streamThread setName:@"stramOne"]; [streamThread start]; } - (void)StreamStart { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; while(!exitNow) { [videoStream Connect]; } [pool release]; } xxx - (void)SwitchCH:(id)objct { NSLog(@"Got to change Channel : %d", [objct intValue]); } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSNumber *nowCH = [NSNumber numberWithInt:row]; [self performSelector:@selector(SwitchCH:) onThread:streamThread withObject:nowCH waitUntilDone:NO]; } 當UIPickerView被選取到某個row, 會變換 channel, 但是我目前這樣的寫法, 無法從 main thread 去 perform streamThread, 請問我該怎麼做才可以讓兩個thread 溝通? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.219.26.209 ※ 編輯: sinread 來自: 124.219.26.209 (10/01 18:14)
zonble:NSPicker?這是什麼 Class? 10/01 18:55
sinread:UIPickerView 沒仔細去看原來的宣告XD 更正一下 10/01 19:16
※ 編輯: sinread 來自: 124.219.26.209 (10/01 19:16)