gpt4 book ai didi

ios - 来自 NSBundle 路径的 NSURL 返回 nil

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:42:26 25 4
gpt4 key购买 nike

所以我尝试使用视频作为背景,我的应用程序中有一个 .mov 文件,当我运行此代码时:

NSBundle * bundle = [NSBundle mainBundle];

NSString * urlString = [bundle pathForResource:@"movie" ofType:@"mov"];
NSURL * movieURL = [NSURL URLWithString:urlString];

if (!movieURL) {

NSLog(@"Not valid");

}

我在控制台中得到 Not valid。我检查了 urlString,它给了我一个 url,我确定该文件命名正确并且不在目录中。

So its here...

所以文件在那里并被复制到源中。不确定为什么要这样做。

最佳答案

你想使用:

NSURL *moveiURL = [NSURL fileURLWithPath:urlString];

更好的是,使用:

NSURL *moveURL = [bundle URLForResource:@"movie" withExtension:@"mov"];

关于ios - 来自 NSBundle 路径的 NSURL 返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25633573/

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