這是我如何創建一個線程:取消NSThread
readFromWebThread = [[NSThread alloc] initWithTarget:self selector:@selector(loadThread:) object:urlStr];
這也是我如何阻止它:
if ([readFromWebThread isExecuting]) {
[readFromWebThread cancel];
}
而且這是我在線程EXCUTE:
-(void)loadThread:(NSString*)urlStr {
while (YES) {
//MyStuff
[NSThread sleepForTimeInterval:kSleepBetweenLoading];
}
}
問題是,即使調用線程繼續調用的取消線程方法。 任何想法可能是什麼錯誤?
添加模擬代碼 –