问题描述
下面的 swift 代码抛出这个错误('Category' 在这个上下文中的类型查找是不明确的)
// ctx is the UIContext,fetchCategories is an Obj-C function that queries CoreData
//for the Categories,the cast shouldn't even be necessary but swift will not
//recognize my obj-c interface
if let cats = self.fetchCategories(ctx) {
let array = cats as! [Category] //error happens on this line
return array
}
这是我的桥接头中的实现, 还有许多其他导入,但我在这篇文章中删除了它们,所以请注意,它是近 40 个其他 .h 文件的全功能桥接头
#ifndef AppDaTaroom_Bridging_Header_h
#define AppDaTaroom_Bridging_Header_h
#import "Category.h"
#endif /* AppDaTaroom_Bridging_Header_h */
下面是接口实现
@interface Category : _Category <QLPreviewItem> {
UIImage *squareThumb;
}
我意识到更改 Category 类的名称将是最好的选择,因为这可能是由于命名约定很常见,但是当我将代码更改为:
if let cats = self.fetchCategories(ctx) {
let array = cats as! [<ModuleName>.Category] //error happens on this line
return array
}
仍然说查找太模糊。除了更改界面名称之外,我还可以尝试关于其他事情的任何想法,因为这确实不是一个选择,我会为您提供所有原因。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)