我在Objective-c中编写的Mac应用程序出现问题。 我有这样的情况:线程释放实例异常
- 在主线程(GUI):
ftEngine = [[FileT alloc] init]; [ftEngine setParameters:searchWord selectedEngine:[[pbEngines selectedItem] title] actualPage:0]; NSThread* thFileT = [[NSThread alloc] initWithTarget:ftEngine selector:@selector(setTotalResult) object:nil]; [thFileT start];
- 在孩子(ftEngine以前的声明):
-(void)setTotalResult { NSError* nsError = nil; NSURL* urlCompleteUrl = [NSURL URLWithString:m_completeSearchWord]; }
m_completeSearchWord由以前使用的setParameters函数初始化。
而现在..我的问题是: 当线程启动时,它调用setTotalResult函数,当我尝试使用m_completeSearchWord时,我会得到一个异常。
这很奇怪,因为如果我不使用线程,所有工作都正常!
的例外是:
2011-09-08 23:24:06.731 GUI[12935:1a07] *** -[CFString respondsToSelector:]: message sent to deallocated instance 0x1003cc650
我已经将它声明为属性: @property(nonatomic,copy)NSString * m_strSearchWord; – Andrea
您是否使用财产设置工具设置财产,还是直接设置了伊娃? –