iOS崩溃日志NSObject didNotRecognizeSelector:-在哪一行?

Arn*_*gel 4 crash-reports ios

我记录了我的应用程序崩溃,但是我的应用程序(5 Control)中的最后一行仅指向方法开始。我怎么知道问题出在哪一行?

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
Run Code Online (Sandbox Code Playgroud)

这里是[冗长]方法代码。我看到可以在其中添加支票的几个地方,但是如何确定才能解决此问题呢?该问题是偶发性的,我无法轻松重现。

- (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);

}
Run Code Online (Sandbox Code Playgroud)

Gra*_*mak 5

简短答案:

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

长答案:

在这里查看堆栈跟踪:

5控件0x10005acb4-[PaymillPaymentService handleTransactionListRequest:](PaymillPaymentService.m:211)

这告诉您在第211行的文件PaymillPaymentService.m中,您正在发送无法对其有效响应PaymillPaymentService的消息handleTransactionListRequest。在与rmaddy,Hot Licks和Paulc11的讨论中,您提到第211行是handleTransactionListRequest的函数条目(无论位于哪个文件中)。如果是这样,那是偶然的。

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