Reputation: 8066
I try to use codes
-(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;
}
it always cause error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]:
incomprehensible archive version (-1)'
at line
NSDictionary *plistDictionary = (NSDictionary*)[NSKeyedUnarchiver unarchiveObjectWithFile:s];
Welcome any comment
Upvotes: 1
Views: 3156
Reputation: 5820
NSKeyedUnarchiver
(and NSKeyedArchiver
) are not for encoding and decoding plists. Instead, they are used to serialize and deserialize objects that implement the NSCoding
protocol. To read your plist data into a dictionary, you instead should use:
NSDictionary *plistDictionary = [NSDictionary dictionaryWithContentsOfFile:s];
Upvotes: 3