我将几个 .svg 文件存储在 Assets 目录中。 要检索 Assets ,我使用以下代码:
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”的文件夹中。我尝试为该文件使用其他扩展名,但没有任何效果。我总是得到同样的错误, Assets 为零。
最佳答案
这可能与我遇到的问题有关,因为我正在识别我的 Assets 的 UTI 可以运行 UTI 依赖项并找到 public.image
,从而使 CoreUI 思考 Assets 是图像类型而不是数据类型。
SVG 继承自 public.image
,因此您需要将文件类型设置为不继承自 public.image
的内容。只需 public.data
就足够了。
关于ios - 无法从存储在 Assets 目录中的文件中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32905549/