[問題] 從 main thread perform 其他的 thread
小弟有一段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)
→
10/01 18:55, , 1F
10/01 18:55, 1F
→
10/01 19:16, , 2F
10/01 19:16, 2F
※ 編輯: sinread 來自: 124.219.26.209 (10/01 19:16)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 10 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章