gpt4 book ai didi

cocoa-touch - 无法使 NSURL 形成字符串

转载 作者:行者123 更新时间:2023-12-03 17:36:00 26 4
gpt4 key购买 nike

我正在尝试读取项目中的文件。我首先使用路径创建一个字符串,然后将其转换为 NSURL,这就是我遇到麻烦的地方:

NSString *sndPath = [[NSBundle mainBundle] pathForResource:@"vader" ofType:@"caf"];
NSURL *url = [NSURL URLWithString:sndPath]; //url is nil!

sndPath的内容是:

/Users/fernando/Library/Application Support/iPhone Simulator/4.3.2/Applications/4B677E62-A6BB-4436-A3DA-EB83A57917FF/Ex1.app/vader.caf

顺便说一句,该文件确实存在。

最佳答案

创建表示文件系统路径的 URL 时,应使用

+[NSURL fileURLWithPath:]

+[NSURL fileURLWithPath:isDirectory:]

关于cocoa-touch - 无法使 NSURL 形成字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7545544/

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