Iphone NSInvocation使应用程序崩溃

Iphone NSInvocation使应用程序崩溃,iphone,ios,objective-c,nsoperationqueue,nsinvocationoperation,Iphone,Ios,Objective C,Nsoperationqueue,Nsinvocationoperation,我的项目是一个基于计算的标准,其中我们填充了通过webservice首次获取的coredata中的必填字段列表 有一个选项可用于计算和重置字段。由于计算需要花费大量时间并冻结应用程序,我使用了NSInvocationOperation将其添加到NSOperationQueue 每当我输入“calculate”时,一个操作正在排队,如果没有时间重置它,应用程序就会崩溃,控制台显示它在调用排队操作的[RiskModel calculate]处崩溃 有没有更好的解决方案来实现这个功能 - (void)

我的项目是一个基于计算的标准,其中我们填充了通过webservice首次获取的
coredata
中的必填字段列表

有一个选项可用于计算和重置字段。由于计算需要花费大量时间并冻结应用程序,我使用了
NSInvocationOperation
将其添加到
NSOperationQueue

每当我输入“calculate”时,一个操作正在排队,如果没有时间重置它,应用程序就会崩溃,控制台显示它在调用排队操作的[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`

你能给我们看一下应用程序崩溃时显示的错误消息吗?在问题“什么代码处于风险模式”中添加了错误。m:第193行?异常消息是什么?-(void)calculate{for(NSMutableDictionary*endPointData in self.endPointDataList){double riskValue=[self-calculateRiskForEndPoint:[endPointData objectForKey:@“endPoint”]procedureId:procedureId];[endPointData setObject:[nsstringwithformat:@“%0.2f”,riskValue]forKey:@“risk”]; } }