在我的 NSOperation 子类中,我在子类方法中的长循环顶部或任何长方法(核心数据提取、数组排序等)之前检查取消main
。请参阅下面的示例。
-(void)main{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for( int i=0; i< 100; i++ )
{
//Check for cancellation
if( [self isCancelled] ){
[pool drain];
return;
}
//Do the work
}
[pool drain];
}
除了排干游泳池并尽快退出该方法之外,我还应该做些什么吗?