2011-06-14 136 views
0

我threeaing一些這樣的任務:iPhone:無法識別的選擇錯誤

RootViewController的

- (void)viewDidLoad { 
[NSThread detachNewThreadSelector:@selector(findSomething) toTarget:self withObject:nil]; 
} 

- (void) findSomething { 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
doMoreThings 
[pool release]; 
} 

- (void) doMoreThings { 
    doMoreMoreMoreThings on different objects 
} 

- (void) foundSomething:(NSFoundThing*)foundObj { 
    do your stuff 
} 

oneObject

- (void) doMoreMoreMoreThings { 
    do things 
[self performSelectorOnMainThread:@selector(foundSomething:) withObject:thingFound waitUntilDone:NO]; 
} 

-[KMLParser foundSomething:]: unrecognized selector sent to instance 0x5888080 

問題是什麼?

回答

1

線程無關緊要。您沒有向我們展示的部分代碼正在實現,因此您要將foundSomething:選擇器發送給不處理該消息的對象。將消息路由到處理它的對象,並且問題將消失。請參閱"Unrecognized selector sent to instance"

+0

在顯示的代碼中發送了哪個對象是我的選擇器? – Oliver 2011-06-14 22:04:59

+0

** oneObject **部分中的哪個對象是'self'。 – 2011-06-14 22:06:21

+0

我會讀一些關於線程的更多內容,但只是一個問題:如果我在oneObject類中有一個foundSomething方法會發生什麼?在線程方面會發生什麼:我已經有了一個主要的thjread,其中有東西跑進去...... – Oliver 2011-06-14 22:10:04

相關問題