gpt4 book ai didi

ios - stringWithContentsOfURL返回(空)

转载 作者:行者123 更新时间:2023-12-01 17:58:13 27 4
gpt4 key购买 nike

我正在尝试使用以下代码将URL转换为字符串:

NSURL *urlOfOpenedFile = _service.myURLRequest.URL;
NSString *fileThatWasOpened = [NSString stringWithContentsOfURL:urlOfOpenedFile encoding:NSASCIIStringEncoding error:nil];

NSLog(@"url: %@", urlOfOpenedFile);
NSLog(@"string: %@", fileThatWasOpened);

返回:
url: file://localhost/Users/User/Library/Application%2520Support/iPhone%2520Simulator/6.0/Applications/72AA03A1-3967-4F22-9745-0722C8DE9FAC/Documents/downloads/My%20Document%20.pdf
string: (null)

谁能告诉我如何将URL转换为字符串?谢谢。

最佳答案

你可以用像
NSString *fileThatWasOpened = [NSString stringWithFormat:@"%@", url];

关于ios - stringWithContentsOfURL返回(空),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13876700/

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