이미 영역에 유지 된 RealmObject의 RealmList에 독립형 객체를 추가 할 수 있습니까?RealmList에 독립형 객체 추가
mRealm.beginTransaction;
contact.getEmails().add(new Email());
mRealm.commitTransaction;
특정 순간에 나는 영역에 대한 액세스 권한을 가지고 있겠지 때문에 : 나는 (object.row.getIndex():RealmList:94
)
에서 NPEs를 얻을 수 있기 때문에
글쎄, 나는 내가하고 싶은 것은,이 일을 나던 알고 예를 들어, (물론 나는 그것이 작동 할 수 있지만, 나는 몇 가지 구조를 다시 작성해야합니다) :
//In Activity
Contact contact = Realm.where(Contact.class).equalsTo("name","pete").findAll().first();
mRealm.beginTransaction;
UpdateHelper.update(contact);
mRealm.commitTransaction;
//Helper class some else package
public static void update(Contact contact) {
//do update stuff
contact.getEmails().add(new Email());
}
`
귀하의 해결책도 내 마음에 왔습니다. Realm 객체를 호출 케스케이드 전체를 통해 전달하는 것보다 다른 옵션이 있는지 명확히하고 싶었습니다. 하지만 오 잘 :) 정말 두 번 트랜잭션을 시작해야합니까? 'UpdateHelper.update()'의 바깥쪽에 또 다시? – degill
아니요. 불필요합니다. 나는 그 모범을 새롭게 할 것이다. –