嗨,我使用Xcode 5+和iOS 7+,並實現NSOperationQueue。我創建了一個NSOpeartion的子類,並說我有50 +操作添加到NSOperationQueue。 isExecuting和isFinished被覆蓋在NSOperation`s啓動方法 -NSOperation完成後,不從NSOperationQueue中刪除?
-(void)start{
// soeme code is here
[self willChangeValueForKey:@"isExecuting"];
_isExecuting = YES;
[self didChangeValueForKey:@"isExecuting"];
[self willChangeValueForKey:@"isFinished"];
_ isFinished = NO;
[self didChangeValueForKey:@"isFinished"];
}
和完成任務後,我編寫此代碼
[self willChangeValueForKey:@"isExecuting"];
_isExecuting = NO;
[self didChangeValueForKey:@"isExecuting"];
[self willChangeValueForKey:@"isFinished"];
_ isFinished = YES;
[self didChangeValueForKey:@"isFinished"];
MaxConcurrentOperationCount爲2但2操作下一個(第三操作)完成之後沒有按不會執行主要方法。請給我一些關於何時出現這個問題的說明。
感謝
上述代碼是否爲您的項目?你沒有設置_isFinished ... – Volker
謝謝,這是我的錯誤,我編輯了上面的代碼。 –