这是坠机报告,不确定原因。我使用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无关。这是服务器端的一个bug (应用程序引擎问题)。我将在一个单独的问题上发表。
[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!!
}发布于 2013-10-21 12:52:17
检查代码崩溃的位置的一个好方法是:
希望这对你有帮助
https://stackoverflow.com/questions/19494708
复制相似问题