coredata
私のプロジェクトは計算ベースの基準であり、 Web サービスを介して最初に取得された必須フィールドのリストを入力します。
フィールドを計算してリセットするオプションがあります。計算に時間がかかり、アプリがフリーズするので、 にNSInvocationOperation
追加して使用しましたNSOperationQueue
。
「計算」を入力するたびに、操作がキューに入れられ、それをリセットするとすぐにアプリがクラッシュし、キューに入れられた操作を呼び出している [RiskModel calculate] でクラッシュしたことがコンソールに表示されます。
この機能を実行するためのより良い解決策はありますか
- (void)calculateRiskAutomatically {
[self.calculateOpQueue cancelAllOperations];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateRiskAutomaticallyWithOperation) object:nil];
[self.calculateOpQueue addOperation:operation];
[operation release];
}
- (void)calculateRiskAutomaticallyWithOperation {
[self.riskModel calculate];
[self performSelectorOnMainThread:@selector(showOutput) withObject:nil waitUntilDone:NO];
}
Thread 5 name: Dispatch queue: com.apple.root.default-priority
Thread 5 Crashed:
0 libobjc.A.dylib 0x3590cfd8 objc_msgSend + 44
1 RiskCalculator 0x000135dc -[RiskModel calculate] (RiskModel.m:193)
2 RiskCalculator 0x0000895e -[RiskModelViewController calculateRiskAutomaticallyWithOperation] (RiskModelViewController.m:82)
3 CoreFoundation 0x344fa80c __invoking___ + 60
4 CoreFoundation 0x344557da -[NSInvocation invoke] + 154
5 Foundation 0x32f4a698 -[NSInvocationOperation main] + 108
6 Foundation 0x32ee339c -[__NSOperationInternal start] + 856
7 Foundation 0x32f4c79c __block_global_6 + 96
8 libdispatch.dylib 0x334f1d4e _dispatch_call_block_and_release + 6
9 libdispatch.dylib 0x334f4890 _dispatch_worker_thread2 + 252
10 libsystem_c.dylib 0x330941c8 _pthread_wqthread + 288
11 libsystem_c.dylib 0x3309409c start_wqthread + 0`