簡體   English   中英

NSKeyedUnarchiver unarchiveObjectWithData:解析塊函數中永不返回

[英]NSKeyedUnarchiver unarchiveObjectWithData: in Parse block function never returns

我從Parse.com請求NSDictionary的文件表示(是的,我知道還有其他更明顯的存儲字典的方式),然后在完成代碼塊中將數據取消存檔並分配給屬性。

執行此代碼后,它似乎永遠不會從取消歸檔行返回。 沒有凍結,沒有錯誤或異常。 該應用程序繼續運行,好像一切正​​常。 如果我在取消存檔器行及其后的行設置斷點,則第一個斷點將被命中,而第二個則不會。

我可以確認該函數已返回該文件的預期數據量。

PFFile *definitionFile = appObject[@"myFile"];  //PFFile reference from a PFObject
[definitionFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
    if (!error) {
        if (data) {
            //A breakpoint on the following line does fire and show that there is data being given to the unarchiver
            self.pendingDefinition = (NSDictionary *) [NSKeyedUnarchiver unarchiveObjectWithData:data];
        }
        //////Nothing beyond this point gets executed////////
        [self handleNewDefinition];
    } else {
        NSLog(@"ERROR");
    }
}];

事實證明,數據被存儲為plist,我需要使用plist序列化來提取它:

if (data) {
            NSError *error;
            NSPropertyListFormat format;
            NSDictionary* plist = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:&error];
            if(!plist){
                NSLog(@"Error: %@",error);
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM