开发者

Read binary plist into NSDictionary

Is there simple way to parse the binary plist file into the NSDictionary representation? I am searching something like that:

NSString* s开发者_开发知识库trings = [NSString stringWithContentsOfURL: ... encoding: NSUnicodeStringEncoding error: ...];
NSMutableDictionary* pairs = (NSMutableDictionary*)[strings propertyListFromStringsFileFormat];

Using this code caused the exception while parsing the binary plist file.


Are you looking for [NSDictionary dictionaryWithContentsOfFile:]?


Considering a file called DataStorageFile.plist, you can use:

NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"DataStorageFile" ofType:@"plist"];
self.data = [NSDictionary dictionaryWithContentsOfFile:dataPath];

If you want an array:

self.data = [NSArray arrayWithContentsOfFile:dataPath];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜