2015-02-05 29 views
0

我请求从Parse.com一个NSDictionary(是的,我知道有存储词典等多种明显的方式),然后在完成块中的数据得到未归档和文件表示分配给一个属性。NSKeyedUnarchiver unarchiveObjectWithData:在解析块函数永远不会返回

当这段代码执行它时,它似乎永远不会从unarchive行中返回。没有冻结,没有错误或例外。该应用程序继续运行,就好像一切都很好。如果我在unarchiver行和后面的行处设置断点,第一个断点会被触发,但第二个断点不会。

我可以证实,该函数返回数据的预期量此文件。

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"); 
    } 
}]; 
+1

是从parse用的NSKeyedArchiver被编码发送到你的数据? NSKeyedUnarchiver只解除已经用NSKeyedArchiver编码的对象 – Msencenb

+0

就是这样。数据正在以plist的形式存储。需要使用plist序列化。 – Dancreek

回答

0

由于原来的数据被存储为一个plist中,我需要使用的plist系列化将其解压:

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