RLMException - RLMArray属性需要一个定义包含类型的协议 - 例如:RLMArray <person>

时间:2016-03-09 14:10:26

标签: ios objective-c realm

我有一个主域对象:

@interface MasterRealmObject : RLMObject

@property (nonatomic, strong) RLMArray<IDNameRealmObject *><IDNameRealmObject> *retailerType;

@property (nonatomic, strong) RLMArray<IDNameRealmObject *><IDNameRealmObject> *firmType;

@property (nonatomic, strong) RLMArray<IDNameRealmObject *><IDNameRealmObject> *businessAge;

@property (nonatomic, strong) RLMArray<StateRealmObject *><StateRealmObject> *state;

@property (nonatomic, strong) RLMArray<KYCDocsRealmObject *><KYCDocsRealmObject> *kycDocs;

@property (nonatomic, strong) RLMArray<ProofRealmObject *><ProofRealmObject> *businessDocs;

@property (nonatomic, strong) NSString *ReligareTollFreeNumber;

@end

我试图将字典中的值存储如下:

-(void)insertMasterAPIObjects:(NSDictionary *)masterDictionary
{

    RLMRealm *realmInsertMasterObjects = [RLMRealm defaultRealm];
    [realmInsertMasterObjects beginWriteTransaction];

    MasterRealmObject *masterRealm = [[MasterRealmObject alloc]init];
    masterRealm.retailerType = [masterDictionary objectForKey:@"retailer_type"];
    masterRealm.firmType = [masterDictionary objectForKey:@"firm_type"];
    masterRealm.businessAge = [masterDictionary objectForKey:@"BusinessAge"];
    masterRealm.kycDocs = [masterDictionary objectForKey:@"kyc_docs"];
    masterRealm.businessDocs = [masterDictionary objectForKey:@"business_docs"];
    masterRealm.state = [masterDictionary objectForKey:@"states"];

    [realmInsertMasterObjects addObject:masterRealm];
    [realmInsertMasterObjects commitWriteTransaction];
}

我在这个方法的第一行得到了这个例外。

1 个答案:

答案 0 :(得分:2)

我遇到了类似的问题,因为我省略了

RLM_ARRAY_TYPE(IDNameRealmObject)
RLM_ARRAY_TYPE(StateRealmObject)
RLM_ARRAY_TYPE(KYCDocsRealmObject)
RLM_ARRAY_TYPE(ProofRealmObject)
在@interface声明之前的

宏。