gpt4 book ai didi

cocoa - pathForResource 不起作用

转载 作者:行者123 更新时间:2023-12-03 16:25:31 26 4
gpt4 key购买 nike

我有问题

NSString *filePaht = [[NSBundle mainBundle] pathForResource:(NSString *)name ofType:(NSString *)ext];

如果我使用

NSString *filePaht = [[NSBundle mainBundle] pathForResource:@"soundName" ofType:@"aiff"];

没关系。但是当我使用时

NSString *fileName = [[file.list objectAtIndex:index] objectForKey:@"soundName"];
NSString *filePaht = [[NSBundle mainBundle] pathForResource:fileName ofType:@"aiff"];

这不是工作

有什么想法吗!?

谢谢

最佳答案

我猜测 file.list 中的 fileName 包含文件扩展名。所以您正在搜索不存在的“soundName.aiff.aiff”。尝试传递 @""作为类型或从文件名中删除扩展名:

fileName = [fileName stringByDeletingPathExtension];

关于cocoa - pathForResource 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2767252/

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