我正在尝试使用以下代码将 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 转换为字符串?谢谢。