要检索资产,我使用以下代码:
NSDataAsset *asset = [[NSDataAsset alloc] initWithname:@"p"];
运行此代码时,我收到以下日志消息:
CoreUI: attempting to lookup a named data ‘p’ with a type that is not a data type in the AssertCatalog
该文件的名称是“p.svg”,它存储在以“dataset”作为扩展名的文件夹中.我尝试使用其他扩展名的文件,但没有任何作用.我总是得到同样的错误,资产是零.
解决方法 只需引用svg或项目中的任何文件,如.h / .m:Nsstring *path = [[NSBundle mainBundle] pathForResource:@"p" ofType:@"svg"];[NSData dataWithContentsOffile:path];
如果path为nil,请尝试:
In the Xcode target "Build Phases" add the file under "copy Bundle Resources"".总结
以上是内存溢出为你收集整理的ios – 无法从存储在资产目录中的文件中获取数据全部内容,希望文章能够帮你解决ios – 无法从存储在资产目录中的文件中获取数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)