1

我尝试使用代码

-(bool)checIfWorksOnJailbreak;
{

    NSString *s = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Info.plist"];

    NSLog(@"%@",s);

    if([[NSFileManager defaultManager] fileExistsAtPath:s]) {


        NSDictionary *plistDictionary =  (NSDictionary*)[NSKeyedUnarchiver unarchiveObjectWithFile:s];


        NSString *valueString = [plistDictionary objectForKey:@"SigerIdentity"];
        if([valueString isEqualToString:@"Apple OS Application Signing"])
            return true;
        else
            return false; 
    }

    return false;

}

它总是导致错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: 
incomprehensible archive version (-1)'

在线

NSDictionary *plistDictionary =  (NSDictionary*)[NSKeyedUnarchiver unarchiveObjectWithFile:s];

欢迎任何评论

4

1 回答 1

3

NSKeyedUnarchiver(and NSKeyedArchiver) 不适用于编码和解码 plist。相反,它们用于序列化和反序列化实现NSCoding协议的对象。要将您的 plist 数据读入字典,您应该使用:

NSDictionary *plistDictionary = [NSDictionary dictionaryWithContentsOfFile:s];
于 2012-06-06T03:24:26.753 回答