读取 plist 时出错:流字节太少,格式:-1073751400
我正在尝试从 plist 中读取一些数据,但收到此错误:“读取 plist 时出错:流字节太少,格式:-1073751400”
任何帮助将不胜感激。
代码:
// read property list into memory as an NSData object
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
// convert static property liost into dictionary object
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
if (!temp)
{
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
}
// assign values
self.excersizesArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];
这是 plist:
I'm trying to read some data out of a plist and I'm getting this error: "Error reading plist: stream had too few bytes, format: -1073751400"
Any help would be much appreciated.
code:
// read property list into memory as an NSData object
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
// convert static property liost into dictionary object
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
if (!temp)
{
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
}
// assign values
self.excersizesArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];
Here's the plist:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能错了,但是“Excersizes”数组不是必须包含在字典本身中吗?
也就是说,您必须在“Excersizes”数组周围放置一个字典标签,如下所示:
至少您使用
指向这个解决方案。这也可能会修复您的解析错误......
I might be mistaken, but doesn't the "Excersizes" array has to be wrapped within an dictionary itself?
That is you have to put a dictionary tag around your "Excersizes" array like this:
At least your use of
points towards this solution. This might fix your parsing error as well...