用其他RLMObjects數組實例化RLMObject的正確方法是什麼?Realm.io數組創建
的文檔不提任何東西,我最初的嘗試(什麼都不做,假設領域做正確的事,並創建一個空數組並指派,當我設置似乎我的第一次關係了不上班。
這裏是我的代碼:
[[RLMRealm defaultRealm] beginWriteTransaction];
[_realmAnswers removeAllObjects];
NSMutableArray* newArray = [NSMutableArray arrayWithCapacity:answers.count];
for (NSString* answerString in answers){
OFEAnswerEntry* newAnswer = [[OFEAnswerEntry alloc] init];
newAnswer.answerString = answerString;
[newArray addObject:newAnswer];
}
[_realmAnswers addObjectsFromArray: newArray];
[[RLMRealm defaultRealm] commitWriteTransaction];
+1指向我的測試,因爲它讓我的解決方案:-) –