领域错误:属性需要一个定义包含类型的协议

我有以下模型,我正在使用Realm

 @interface GUIRoutineModel : GUIModel # GUIModel is a subclass of RLMObject @property (nonatomic, retain) NSString *dateCreated; @property (nonatomic, retain) NSString *dateModified; @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *type; @property NSInteger userId; @property int routineId; #also have same issue using NSInteger @end 

我打电话的时候:

  // Persist to Realm DB RLMRealm *realm = [RLMRealm defaultRealm]; [realm transactionWithBlock:^{ [realm addObject:routineModel]; }]; 

我收到以下错误:

 'Property 'routineId' requires a protocol defining the contained type - example: NSNumber.' 

我已经尝试将routineId属性更改为NSNumber ,但这也不起作用。 谁能告诉我我做错了什么?

更新:

这是我尝试的另一个版本的模型:

 @interface GUIRoutineModel : GUIModel @property (nonatomic, retain) NSString *dateCreated; @property (nonatomic, retain) NSString *dateModified; @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *type; @property NSInteger userId; @property NSNumber *routineId; @end 

Property requires a protocol defining the contained type error仅由Realm为NSNumber类型的属性生成,而没有注释预期具体类型的协议。 这意味着无法为您提到的任何一个模型类生成它。 您可能在应用程序的其他routineId有另一个routineId属性触发错误。