Dhananjay Suresh
Dhananjay Suresh

Reputation: 1286

Realm throwing RLMException when checking equality on property

Whenever I try to check equality between a property on a Realm object and a NSInteger, it throws the following exception:

*** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'

However I am not modifying the object, just accessing it. Do I have to start a write transaction to check equality?

If I put a breakpoint right at the start of the if statement, the next step in throws the exception.

//message is a RLMObject stored in a RLMResults array
if (message.status == 3 || message.status == 4) {
    NSLog(@"Message status: %ld", (long)message.status);
}

Upvotes: 0

Views: 255

Answers (1)

Dhananjay Suresh
Dhananjay Suresh

Reputation: 1286

The issue was that I was querying and modifying the RLMObject elsewhere in the setup of another view controller. This was causing the exception to be thrown. My fault for not looking closely at what my other code was doing.

Upvotes: 0

Related Questions