无法理解Apple崩溃日志 - [NSObject(NSObject)doesNotRecognizeSelector:]

时间:2013-10-11 03:22:20

标签: ios ios7 crash-reports

这很奇怪,我可以使用Xcode 5(5A1413)在模拟器,iPhone 4S和iPhone 5中运行我的应用程序,没有任何问题但是当我将应用程序提交到iTunes商店时被拒绝,这个日志是从Apple提供的。

这是我从Apple获得的信息:

  

我们发现您的应用在运行iOS 7.0.2的iPhone 5上崩溃,这不符合App Store评论指南。

我承认我无能为力,请你帮我理解这个崩溃日志:

Incident Identifier: 17461001-CE5D-451F-9BD5-FF513B76B03E
CrashReporter Key:   298a52ed29ad5cd48b1f745f998491771bd584a6
Hardware Model:      iPhone5,1
Process:             HomeClubBanesco [485]
Path:                /var/mobile/Applications/6C36584D-E12D-4BDB-995A-B1652CDA9E48/HomeClubBanesco.app/HomeClubBanesco
Identifier:          com.3pixelsmedia.HomeClubBanesco
Version:             2 (1.1)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2013-10-10 23:21:28.291 -0430
OS Version:          iOS 7.0.2 (11A501)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x31462e86 __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x3b75d6c2 objc_exception_throw + 34
2   CoreFoundation                  0x314667b2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198
3   CoreFoundation                  0x314650b2 ___forwarding___ + 702
4   CoreFoundation                  0x313b3e94 __forwarding_prep_0___ + 20
5   Foundation                      0x31e05e78 -[_NSPlaceholderData initWithData:] + 124
6   HomeClubBanesco                 0x00106b76 -[HCBAppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] (HCBAppDelegate.m:315)
7   UIKit                           0x33efe45a _UIXXRemoteNotificationRegistrationSucceeded + 146
8   UIKit                           0x33efefc4 _XRemoteNotificationRegistrationSucceeded + 88
9   AppSupport                      0x34c73b32 migHelperRecievePortCallout + 186
10  CoreFoundation                  0x3142d77a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
11  CoreFoundation                  0x3142d716 __CFRunLoopDoSource1 + 342
12  CoreFoundation                  0x3142bee2 __CFRunLoopRun + 1402
13  CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
14  CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
15  GraphicsServices                0x360cd2e6 GSEventRunModal + 134
16  UIKit                           0x33c4d1e0 UIApplicationMain + 1132
17  HomeClubBanesco                 0x00105812 main (main.m:17)
18  libdyld.dylib                   0x3bc56ab2 tlv_initializer + 2


Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3bd0d1fc __pthread_kill + 8
1   libsystem_pthread.dylib         0x3bd74a4e pthread_kill + 54
2   libsystem_c.dylib               0x3bcbe028 abort + 72
3   libc++abi.dylib                 0x3b10c98a abort_message + 70
4   libc++abi.dylib                 0x3b1256e2 default_terminate_handler() + 250
5   libobjc.A.dylib                 0x3b75d936 _objc_terminate() + 190
6   libc++abi.dylib                 0x3b1231b0 std::__terminate(void (*)()) + 76
7   libc++abi.dylib                 0x3b122d12 __cxa_rethrow + 98
8   libobjc.A.dylib                 0x3b75d80a objc_exception_rethrow + 38
9   CoreFoundation                  0x313965b2 CFRunLoopRunSpecific + 638
10  CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
11  GraphicsServices                0x360cd2e6 GSEventRunModal + 134
12  UIKit                           0x33c4d1e0 UIApplicationMain + 1132
13  HomeClubBanesco                 0x00105812 main (main.m:17)
14  libdyld.dylib                   0x3bc56ab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x3bcfa838 kevent64 + 24
1   libdispatch.dylib               0x3bc490d0 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x3bc4363e _dispatch_mgr_thread + 34

Thread 2:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 3:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 4:
0   libsystem_kernel.dylib          0x3bcfaa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bcfa87c mach_msg + 36
2   CoreFoundation                  0x3142d55c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x3142bc7c __CFRunLoopRun + 788
4   CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x313da1a6 CFRunLoopRun + 94
6   CoreMotion                      0x31a4e394 ___lldb_unnamed_function1407$$CoreMotion + 724
7   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
8   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
9   libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 5 name:  com.apple.NSURLConnectionLoader
Thread 5:
0   libsystem_kernel.dylib          0x3bcfaa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bcfa87c mach_msg + 36
2   CoreFoundation                  0x3142d55c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x3142bc7c __CFRunLoopRun + 788
4   CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
6   Foundation                      0x31dd164c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7   Foundation                      0x31e46dc2 __NSThread__main__ + 1058
8   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
9   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
10  libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 6:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 7:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 8:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 9 name:  com.apple.CFSocket.private
Thread 9:
0   libsystem_kernel.dylib          0x3bd0d440 select$DARWIN_EXTSN + 20
1   CoreFoundation                  0x3143145e __CFSocketManager + 482
2   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
3   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
4   libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x00002060
    r4: 0x00000006    r5: 0x3db3a18c      r6: 0x00000000      r7: 0x27d03584
    r8: 0x15e958a0    r9: 0x00000001     r10: 0x31f15124     r11: 0x00000000
    ip: 0x00000148    sp: 0x27d03578      lr: 0x3bd74a53      pc: 0x3bd0d1fc
  cpsr: 0x00000010

已更新以显示已损坏的方法

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

 NSLog(@"Usuario SI Acepto las notificaciones");
[self setDToken:deviceToken];
NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:HCBDeviceTokenPrefKey]];
if (![myToken isEqualToData:deviceToken]) {
    NSLog(@"Token no coincide");
        [[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:HCBDeviceTokenPrefKey];
    // Debo actualizar los datos en la db.
    if (![[[NSUserDefaults standardUserDefaults] objectForKey:HCBUserIDPrefKey] isEqualToString:@"1"]) {
        NSString *urlString = [NSString stringWithFormat:@"http://cmx.3pixelsmedia.com/homeclub/?l=iphone&updateDeviceID&deviceToken=%@&userID=%@",
                               deviceToken,
                               [[NSUserDefaults standardUserDefaults] objectForKey:HCBUserIDPrefKey]];
        NSLog(@"urlString : %@",urlString);
    }
}

NSLog(@"Device Token : %@",myToken);
}

1 个答案:

答案 0 :(得分:1)

在应用审核期间,您的应用收到了EXC_CRASH (SIGABRT)异常。这意味着在您的应用中运行的代码检测到错误,因此它要求操作系统终止您的进程,这是通过SIGABRT信号完成的。

异常终止的原因是,在调度方法请求时,Objective-C运行时检测到doesNotRecognizeSelector问题,如异常回溯中所见

2   CoreFoundation                  0x314667b2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198

引起这种情况的代码是:

NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:HCBDeviceTokenPrefKey]];

这是因为NSData将假定用户默认值具有设备令牌的NSData结果。 如果没有得到合适的NSData对象,它将向未知该NSData私有implementation class的对象发送-[_NSPlaceholderData initWithData:]构造函数消息

只需仔细检查以下测试代码即可通过实验证明这一点:

NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@"SomeKey"]];

NSLog(@"My data is %@ - ok since we can handle a nil", myToken);

id stringProperty = @"Some string";
NSData *problemToken = [[NSData alloc] initWithData:stringProperty];

NSLog(@"My data is %@ - we have probably crashed by now", problemToken);

退后一步,重要的是要了解崩溃通常不是由于代码本身引起的,而是由于代码所运行的环境引起的。

您的工作和失败案例有两个不同的因素。

  1. 您的本地应用可能从先前的运行设置中获得了带有NSData令牌的用户默认值。
  2. 您的应用本地测试可能使用的Debug版本配置(与默认值相比)与您的Release版本(将发送给Apple)不同。

尝试的事情:

  1. 在模拟器中,清除内容和设置,然后重试您的应用。
  2. 在Xcode(架构设置)中,将部署版本从“调试”更改为“发布”。
  3. 输入用于测试值类型的代码来自HCBUserIDPrefKey的“用户默认值”。确保它是NSData(还要检查nil)。