Attempting to Modify Object Outside of Write Transaction

前端 未结 1 2055
名媛妹妹
名媛妹妹 2021-02-14 02:32

So I have no idea why I am getting this error. The error message is as follows:

* Terminating app due to uncaught exception \'RLMException\', reason: \'Attemptin

相关标签:
1条回答
  • 2021-02-14 02:48

    The beginWriteTransaction and commitWriteTransaction have to be called on the same realm the object you're modifying is in. Each time you call [RLMRealm defaultRealm], you're getting a new realm. This is not going to be the same realm that's in self.chatSession. To fix this, first confirm that self.chatSession's realm is on the same queue as your queueForWrites (I'm assuming self.chatSession is a RLMObject, of course). Then, just do the following inside the block instead:

    [self.chatSession.realm beginWriteTransaction];
    self.chatSession.myAlias = alertTextField.text;
    [self.chatSession.realm commitWriteTransaction];
    
    0 讨论(0)
提交回复
热议问题