gpt4 book ai didi

objective-c - 读取 plist : stream had too few bytes, 格式时出错:-1073751400

转载 作者:行者123 更新时间:2023-11-29 04:56:29 25 4
gpt4 key购买 nike

我试图从 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:

enter image description here

最佳答案

我可能错了,但是“Excersizes”数组不是必须包含在字典本身中吗?

也就是说,您必须在“Excersizes”数组周围放置一个字典标记,如下所示:

<dict>
<key>Excersizes</key>
<array>
...
</array>
</dict>

至少你使用

self.excersizesArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];

指向此解决方案。这也可能会修复您的解析错误...

关于objective-c - 读取 plist : stream had too few bytes, 格式时出错:-1073751400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7867836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com