gpt4 book ai didi

ios - 读取 xml 文件时得到 NSCocoaErrorDomain code=261

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

我正在尝试使用以下代码读取 COLLADA 文件(xml 格式,utf-8 编码):

NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"astroBoy_walk_Max" ofType:@"dae"];
NSError *error;
NSString *xmlContent = [NSString stringWithContentsOfFile:xmlPath encoding:NSUTF8StringEncoding error:&error];

返回的 xmlContent 为零且错误 @"NSCocoaErrorDomain"- 代码:261。

然后我尝试使用其他编码,例如 NSASCIIStringEncoding,xmlContent 不是 nil,而是包含字符串 "bplist00Ô\x01\x02\x03\x04\x05\x06\a\bZzippedData_\x10\x1creaderMinimumRequiredVersionVzippedWversionO\x12..." 这显然不是原始文件内容。

后来我将文件的扩展名重命名为dat,并使用几乎相同的代码进行读取:

NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"astroBoy_walk_Max" ofType:@"dat"];
NSError *error;
NSString *xmlContent = [NSString stringWithContentsOfFile:xmlPath encoding:NSASCIIStringEncoding error:&error];

一切看起来都很好,xmlContent 包含正确的文件内容字符串...

读取原始 .dae 文件时出现什么问题?

最佳答案

collada 文件在编译时被压缩

When you include a scene file in Collada or Alembic format in your Xcode project, Xcode automatically converts the file to SceneKit’s compressed scene format for use in the built app. The compressed file retains its original .dae or .abc extension.

来自 Apple Documentation

如果您打开应用程序包并以文本形式阅读 collada 文件,您会发现它与您添加到项目中的文件不同

关于ios - 读取 xml 文件时得到 NSCocoaErrorDomain code=261,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26900425/

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