我有以下模型,我正在使用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<RLMInt>.'
我尝试将routineId
属性更改为NSNumber<RLMint>
,但这也无效。谁能告诉我我做错了什么?
更新:
这是我尝试的另一个版本的模型:
@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<RLMInt> *routineId;
@end
答案 0 :(得分:6)
Property requires a protocol defining the contained type error
仅由Realm为NSNumber
类型的属性生成,没有协议注释预期的具体类型。这意味着无法为您提到的任何一个模型类生成它。您可能在应用中的其他地方有另一个routineId
属性触发了错误。