在 Swift&Objc 混合应用程序中,Xcode 找不到 Realm 对多关系的协议



出于某种原因,我需要在我的项目中有一些对象代码,但所有的新代码都是用Swift编写的。我开始将Realm添加到项目中。由于RealmSwift不能在混合应用程序中使用,所以我需要使用Realm Objective-C。

所以我定义了我的两个模型:项目和评估:

@interface Item : RLMObject
@property NSString *name;
@property NSString *upc;
@property Appraisal *appraisal;
@end
RLM_ARRAY_TYPE(Item)
@interface Appraisal : NSObject
@property NSString *name;
@property RLMArray<Item> *items;
@end

我需要在我的新Swift代码中使用这些模型,所以我把它们放在桥接头文件中。这样的:

#import "Item.h"
#import "Appraisal.h"

只要我在桥接头中有它们,我就无法编译代码,因为错误" cannot find protocol declaration for "item"。

有人见过这个并且有解决方案吗?

提前感谢!

既然您的错误信息是Cannot find protocol declaration for "item",那么您可能写的是RLMArray<item>而不是RLMArray<Item> ?

最新更新