gpt4 book ai didi

objective-c - 使用 stringWithContentsOfFile : 读取文件时出现问题

转载 作者:行者123 更新时间:2023-11-28 18:45:05 24 4
gpt4 key购买 nike

在我的应用程序中,我必须读取 XML 文件并将其显示在 UITextView 中。为此,我尝试了下面的代码。此代码导致崩溃;谁能告诉我确切的错误?希望我写的好。请帮帮我。谢谢。

-(IBAction)xmlParse{

NSString *xmlPath=[[[[UIApplication sharedApplication]delegate] applicationDocumentDirectory]stringByAppendingPathComponent:@"xmlFile/toc.xml"];
NSError *error=nil;
NSString *fileContent=[NSString stringWithContentsOfFile:xmlPath usedEncoding:NSASCIIStringEncoding error:NULL];
xmlDisplay.text=fileContent;

}

最佳答案

替换

NSString *fileContent=[NSString stringWithContentsOfFile:xmlPath usedEncoding:NSASCIIStringEncoding error:NULL];

NSString *fileContent=[NSString stringWithContentsOfFile:xmlPath encoding:NSASCIIStringEncoding error:NULL];

你不应该忽略 assing argument 2 of 'stringWithContentsOfFile:usedEncoding:error:' makes pointer from integer without a cast编译器会向您显示警告。

关于objective-c - 使用 stringWithContentsOfFile : 读取文件时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5406001/

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