1

这是崩溃报告,不知道为什么。我使用 AFHTTPRequestOperation setCompletionBlockWithSuccess:failure: 拨打电话。在完成块中,我得到结果并将其传递给我的数据模型上的类别类以插入到核心数据表中。

以下是崩溃日志..

最后异常回溯:

0   CoreFoundation                  0x2fed7f4e __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x3a2b06aa objc_exception_throw + 34
2   CoreFoundation                  0x2fedb8e2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198
3   CoreFoundation                  0x2feda1ce ___forwarding___ + 702
4   CoreFoundation                  0x2fe29594 __forwarding_prep_0___ + 20
5   <myappname>                     0x000bbfe8 +[BTRooms(Data) createNewRoom:withNode:] (BTRooms+Data.m:32)
6   <myappname>                     0x000b034e __28-[BTNet createRoom:friends:]_block_invoke (BTNet.m:551)
7   <myappname>                     0x0008fd10 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke139 (AFHTTPRequestOperation.m:279)
8   libdispatch.dylib               0x3a793d76 _dispatch_call_block_and_release + 6
9   libdispatch.dylib               0x3a793d62 _dispatch_client_callout + 18
10  libdispatch.dylib               0x3a79a7bc _dispatch_main_queue_callback_4CF$VARIANT$mp + 264
11  CoreFoundation                  0x2fea281c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
12  CoreFoundation                  0x2fea10f0 __CFRunLoopRun + 1296
13  CoreFoundation                  0x2fe0bce2 CFRunLoopRunSpecific + 518
14  CoreFoundation                  0x2fe0bac6 CFRunLoopRunInMode + 102
15  GraphicsServices                0x34b2c27e GSEventRunModal + 134
16  UIKit                           0x326ada3c UIApplicationMain + 1132
17  <myappname>                     0x0005e280 main (main.m:16)
18  libdyld.dylib                   0x3a7b8ab2 tlv_initializer + 2

崩溃的线程

0   libsystem_kernel.dylib          0x3a86f1fc __pthread_kill + 8
1   libsystem_pthread.dylib         0x3a8d8a2e pthread_kill + 54
2   libsystem_c.dylib               0x3a81fff8 abort + 72
3   libc++abi.dylib                 0x39b4ecd2 abort_message + 70
4   libc++abi.dylib                 0x39b676e0 default_terminate_handler() + 248
5   libobjc.A.dylib                 0x3a2b091e _objc_terminate() + 190
6   libc++abi.dylib                 0x39b651c4 std::__terminate(void (*)()) + 76
7   libc++abi.dylib                 0x39b64a18 __cxa_throw + 112
8   libobjc.A.dylib                 0x3a2b077e objc_exception_throw + 246
9   CoreFoundation                  0x2fedb8e2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198
10  CoreFoundation                  0x2feda1ce ___forwarding___ + 702
11  CoreFoundation                  0x2fe29594 __forwarding_prep_0___ + 20
12  <myappname>                     0x000bbfea +[BTRooms(Data) createNewRoom:withNode:] (BTRooms+Data.m:32)
13  <myappname>                     0x000b0350 __28-[BTNet createRoom:friends:]_block_invoke (BTNet.m:551)
14  <myappname>                     0x0008fd12 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke139 (AFHTTPRequestOperation.m:279)
15  libdispatch.dylib               0x3a793d78 _dispatch_call_block_and_release + 8
16  libdispatch.dylib               0x3a793d64 _dispatch_client_callout + 20
17  libdispatch.dylib               0x3a79a7bc _dispatch_main_queue_callback_4CF$VARIANT$mp + 264
18  CoreFoundation                  0x2fea281c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
19  CoreFoundation                  0x2fea10f0 __CFRunLoopRun + 1296
20  CoreFoundation                  0x2fe0bce2 CFRunLoopRunSpecific + 518
21  CoreFoundation                  0x2fe0bac6 CFRunLoopRunInMode + 102
22  GraphicsServices                0x34b2c27e GSEventRunModal + 134
23  UIKit                           0x326ada3c UIApplicationMain + 1132
24  <myappname>                     0x0005e280 main (main.m:16)
25  libdyld.dylib                   0x3a7b8ab4 start + 0

请给我一些关于崩溃日志的见解。我已经做了几个小时了。

这是我的代码..

MyClient* client = [MyClient sharedClient];
[client setParameterEncoding:AFJSONParameterEncoding];
NSMutableURLRequest* request = [client requestWithMethod:@"POST" path:@"/JoinRoom" parameters:data];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[client registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

// Print the response body in text
//NSString* responseText = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSError* error3;
NSDictionary* json = [NSJSONSerialization
                      JSONObjectWithData:responseObject //1
                      options:0
                      error:&error3];
NSString* status = [json objectForKey:@"status"];
if ([status isEqualToString:kBTOK]){ // OK

    NSDictionary* room = [json objectForKey:@"data"];
    BTRooms* newRoom = [BTRooms createNewRoom:room withNode:@""];
}
else{
// Do something else
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// Do something else
}];

[[[MyClient sharedClient] operationQueue] addOperation:operation];

[BTRooms createNewRoom:room withNode:@""] 看起来像这样..

+ (BTRooms*) createNewRoom:(NSDictionary *)roomDic withNode: (NSString*) node{
    NSString* roomId = [roomDic objectForKey:@"roomid"];
//more code here
}

当我使用 xCode 连接和调试时,它不会崩溃。当应用程序在后台运行一段时间并且我在设备中运行它时,它会随机崩溃。进行远程调用的是我的标签栏控制器视图控制器之一。

新更新

弄清楚了!对不起,误导性的问题。与iOS无关。这是来自服务器端的错误(应用程序引擎问题)。我将在一个单独的问题中发布。

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

NSError* error3;
NSDictionary* json = [NSJSONSerialization
                      JSONObjectWithData:responseObject //1
                      options:0
                      error:&error3];
NSString* status = [json objectForKey:@"status"];
if ([status isEqualToString:kBTOK]){ // OK

    NSDictionary* room = [json objectForKey:@"data"];
    // room is null here!!
}
4

1 回答 1

5

检查代码崩溃位置的一个好方法是:

  1. 转到 Xcode 中的断点选项卡。
  2. 点击底部的“+”按钮。
  3. 添加异常断点
    • 在 break 选项卡中同时选择:on Throw 和 on Catch,然后构建并运行。
  4. 这些断点将为您提供 90% 的应用程序崩溃的确切位置。

希望这可以帮助你

于 2013-10-21T12:52:17.950 回答