2014-08-29 53 views
5

我正在为CloudKit编写初始化方法。提取用户ID /帐户状态时出现问题。我的电话是[[CKContainer defaultContainer] fetchUserRecordIDWithCompletionHandler:]iOS CloudKit崩溃完成块for -fetchUserRecordIDWithCompletionHandler:

它稍后崩溃,调试器将我指向“Queue:com.apple.cloudkit.operation.callback(serial)queue”线程。

此方法是具有应执行的回调的唯一CloudKit相关方法。

这里的方法本身:

[[CKContainer defaultContainer] fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) { 
    NSLog(@"CLOUDKIT Fetching User Record ID"); 

    if (error) { 
     NSLog(@"[%@] Error loading CloudKit user: %@", self.class, error); 
    } 

    if (recordID) { 
     NSLog(@"CLOUDKIT Found User Record ID: %@", recordID.recordName); 

     // If there is a record ID we check for account status 
     [[CKContainer defaultContainer] accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error) { 
      NSLog(@"CLOUDKIT Finding Account Status"); 

      if (error) { 
       NSLog(@"[%@] Error checking CloudKit availability: %@", self.class, error); 
      } 

      if (accountStatus == CKAccountStatusAvailable) { 
       NSLog(@"CLOUDKIT Account Available, beginning initial sync"); 
       // We have an available account. If we have a new user do a complete sync 
       NSString *userRecordID = [[NSUserDefaults standardUserDefaults] stringForKey:CLOUD_KIT_CURRENT_USER_ID_USER_DEFAULT]; 
       if (userRecordID == nil || ![recordID.recordName isEqualToString:userRecordID]){ 
        [self syncAllData]; 
       } else { 
        // If there haven't been any updates, just sync as usual 
        [self syncChanges]; 
       } 

       // Subscribe to zone updates 
       [self subscribeToDefaultZoneUpdates]; 
      } else { 
       NSLog(@"[%@] Cloudkit account is either unavailable or restricted", self.class); 
      } 
     }]; 
    } else { 
     NSLog(@"[%@] CloudKit user Record ID not found", self.class); 
    } 
}]; 

有这个前后正在执行,但NSLog的最顶部(“CLOUDKIT获取用户记录ID”)永远不会被执行NSLogs。

当它崩溃的日志不给我任何信息。下面是从Xcode的线程队列:

enter image description here

下面是它实际上在调试导航吐出来。

libsystem_kernel.dylib`__pthread_kill: 
0x332f7df4: mov r12, #0x148 
0x332f7df8: svc #0x80 
0x332f7dfc: blo 0x332f7e14    ; __pthread_kill + 32 
0x332f7e00: ldr r12, [pc, #4]    ; __pthread_kill + 24 
0x332f7e04: ldr r12, [pc, r12] 
0x332f7e08: b  0x332f7e10    ; __pthread_kill + 28 
0x332f7e0c: rsbeq lr, r6, #0x80000001 
0x332f7e10: bx  r12 
0x332f7e14: bx  lr 

具体来说,它是打破在0x332f7dfc: blo 0x332f7e14 ; __pthread_kill + 32

+0

你真的崩溃了吗?意思是,如果你在调试器中点击“继续”,你会继续吗?你有没有尝试击中它,直到发生什么事情?您是否启用了“所有例外”断点?你打破了哪条特定路线?有时,苹果的API会出于任何原因抛出非致命的异常,我已经在AVAudioPlayer上看到过它。 – 2014-08-29 22:47:46

+0

点击继续不会给我任何新信息。它只是吐出更多的装配,直到我陷入困境。它不给我一个行号。休息时间在调试导航器中。 – Jonathan 2014-08-29 22:58:24

+0

它实际上是打破看起来像这样一点: libsystem_kernel.dylib'__pthread_kill: 0x332f7df4:MOV R12,#0x148 0x332f7df8:SVC#0x80的 0x332f7dfc:BLO 0x332f7e14; __pthread_kill + 32 0x332f7e00:ldr r12,[pc,#4]; __pthread_kill + 24 0x332f7e04:ldr r12,[pc,r12] 0x332f7e08:b 0x332f7e10; __pthread_kill + 28 0x332f7e0c:rsbeq lr,r6,#0x80000001 0x332f7e10:bx r12 0x332f7e14:bx lr – Jonathan 2014-08-29 22:58:45

回答

0

好的,所以我确定了这一点。

我回滚到上次工作,并且更改了除FastPDFKit生成的某些二进制文件之外的所有内容。我这样做后,它开始工作正常。不知道那里有什么搞乱它,但它现在起作用。

2

你的方法的顺序不正确/不完整的。这是你应该做的:你首先必须调用accountStatusWithCompletionHandler来查看你是否被吸引到了iCloud中。那么如果是这种情况,您必须调用requestApplicationPermission来查看是否允许您查询iCloud。如果这是真的,那么您可以执行fetchUserRecordIDWithCompletionHandler来获取您的ID,然后执行discoverUserInfoWithUserRecordID以获取详细信息。如果你想看一个样本,那么看看Apple的CloudKitAtlas演示:https://developer.apple.com/library/prerelease/ios/samplecode/CloudAtlas/Introduction/Intro.html#//apple_ref/doc/uid/TP40014599-Intro-DontLinkElementID_2

+0

我试过了,它还在破。我构建了一个可以完成相同任务的应用程序,并且该应用程序在别处打开它给了我一个没有实际输出的SIGBART,所以我不得不回滚到最后一个工作版本,我正在从那里前进。不知道什么是错的。 – Jonathan 2014-09-03 21:04:29