iOS崩溃日志NSObject doesNotRecognizeSelector: – 在哪一行?

我logging了我的应用程序崩溃,但在我的应用程序(5控制)的最后一行只是方法开始。 我怎么知道问题在哪一行?

0 CoreFoundation 0x185f0af50 __exceptionPreprocess + 132 1 libobjc.A.dylib 0x1924141fc objc_exception_throw + 60 2 CoreFoundation 0x185f0fc04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 220 3 CoreFoundation 0x185f0d930 ___forwarding___ + 912 4 CoreFoundation 0x185e2d5dc _CF_forwarding_prep_0 + 92 5 Control 0x10005acb4 -[PaymillPaymentService handleTransactionListRequest:] (PaymillPaymentService.m:211) 6 Foundation 0x186a7416c __103+[__NSOperationInternal _observeValueForKeyPath:ofObject:changeKind:oldValue:newValue:indexes:context:]_block_invoke96 + 28 7 libdispatch.dylib 0x1929ec014 _dispatch_call_block_and_release + 24 8 libdispatch.dylib 0x1929ebfd4 _dispatch_client_callout + 16 9 libdispatch.dylib 0x1929f32b8 _dispatch_root_queue_drain + 556 10 libdispatch.dylib 0x1929f34fc _dispatch_worker_thread2 + 76 11 libsystem_pthread.dylib 0x192b816bc _pthread_wqthread + 356 12 libsystem_pthread.dylib 0x192b8154c start_wqthread + 4 

这里是[冗长的]方法代码。 我看到有几个地方可以添加支票,但是我怎么知道这个问题是肯定的,我解决了这个问题呢? 问题是零星的,我不能轻易地重现它。

 - (void)handleTransactionListRequest:(ServiceRequest *)serviceRequest { LRURLRequestOperation* operation = serviceRequest.operation; NSHTTPURLResponse *response = (NSHTTPURLResponse *)operation.URLResponse; if (response.statusCode == 200) { if (operation.responseData) { NSError *parserError = nil; NSDictionary *data = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:&parserError]; //NSLog(@"%@", data); if (!parserError) { NSArray* transactions = [data objectForKey:@"data"]; if (0 == serviceRequest.currentOffset) { NSNumber* totalCountObj = [data objectForKey:@"data_count"]; serviceRequest.totalCount = [totalCountObj intValue]; } int loadedCount = 0; if (transactions) { for (id object in transactions) { TransactionInfo* info = [self createTransactionFrom:object]; [serviceRequest.transactionList addTransaction:info]; [info release]; loadedCount++; } } if (loadedCount + serviceRequest.currentOffset >= serviceRequest.totalCount) { if ([serviceRequest.delegate respondsToSelector:@selector(transactionListLoadingComplete:)]) [serviceRequest.delegate transactionListLoadingComplete:serviceRequest]; serviceRequest.transactionList.timeStamp = [[NSDate date] timeIntervalSince1970]; NSLog(@"COMPLETE: %d transaction loaded ", serviceRequest.totalCount); } else { serviceRequest.currentOffset += loadedCount; bool needToContinue = YES; if ([serviceRequest.delegate respondsToSelector:@selector(transactionListLoadingContinue:)]) needToContinue = [serviceRequest.delegate transactionListLoadingContinue]; if (needToContinue) { [self continueRetrievingTransactionListFor:serviceRequest]; NSLog(@"CONTINUE: %d of %d loaded ", serviceRequest.currentOffset, serviceRequest.totalCount); } } return; // all OK cases } } } if ([serviceRequest.delegate respondsToSelector:@selector(transactionListLoadingFailed:with:)]) [serviceRequest.delegate transactionListLoadingFailed:serviceRequest with:response.statusCode]; NSLog(@"ERROR: Loading Transactions Response Code: %ld", (long)response.statusCode); } 

简答:

您正在向不能有效响应的对象发送消息。 堆栈跟踪告诉你,当你进行调用[PaymillPaymentService handleTransactionListRequest:] PaymillPaymentService不能接受handleTransactionListRequest。

很长的回答:

看看这里的堆栈跟踪:

5控制0x10005acb4 – [PaymillPaymentService handleTransactionListRequest:](PaymillPaymentService.m:211)

这是告诉你,在211线上的文件PaymillPaymentService.m你正在发送PaymillPaymentService消息handleTransactionListRequest它不能有效地响应。 在你与rmaddy,Hot Licks和Paulc11的讨论中,你提到了第211行是handleTransactionListRequest的函数入口(在它所驻留的任何文件中)。 如果是这样的话,这是巧合。

如果您想进一步跟进,您需要发布PaymillPaymentService.m并确保包含所有行号。