{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/1992","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1992/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1992/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1992/events","html_url":"https://github.com/realm/realm-cocoa/issues/1992","id":80556030,"number":1992,"title":"Update an object that has been retrieved via short hand.","user":{"login":"ArEnSc","id":6252325,"avatar_url":"https://avatars.githubusercontent.com/u/6252325?v=3","gravatar_id":"","url":"https://api.github.com/users/ArEnSc","html_url":"https://github.com/ArEnSc","followers_url":"https://api.github.com/users/ArEnSc/followers","following_url":"https://api.github.com/users/ArEnSc/following{/other_user}","gists_url":"https://api.github.com/users/ArEnSc/gists{/gist_id}","starred_url":"https://api.github.com/users/ArEnSc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArEnSc/subscriptions","organizations_url":"https://api.github.com/users/ArEnSc/orgs","repos_url":"https://api.github.com/users/ArEnSc/repos","events_url":"https://api.github.com/users/ArEnSc/events{/privacy}","received_events_url":"https://api.github.com/users/ArEnSc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/realm/realm-cocoa/labels/pending","name":"pending","color":"ededed"},{"url":"https://api.github.com/repos/realm/realm-cocoa/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"jpsim","id":474794,"avatar_url":"https://avatars.githubusercontent.com/u/474794?v=3","gravatar_id":"","url":"https://api.github.com/users/jpsim","html_url":"https://github.com/jpsim","followers_url":"https://api.github.com/users/jpsim/followers","following_url":"https://api.github.com/users/jpsim/following{/other_user}","gists_url":"https://api.github.com/users/jpsim/gists{/gist_id}","starred_url":"https://api.github.com/users/jpsim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpsim/subscriptions","organizations_url":"https://api.github.com/users/jpsim/orgs","repos_url":"https://api.github.com/users/jpsim/repos","events_url":"https://api.github.com/users/jpsim/events{/privacy}","received_events_url":"https://api.github.com/users/jpsim/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-05-25T14:38:18Z","updated_at":"2015-05-26T22:11:03Z","closed_at":null,"body":"I understand in Realm to update an object that has been retrieved I must update it in this context.\r\n\r\n\r\n```objective-c\r\n\r\n// Creating a book with the same primary key as a previously saved book\r\nBook *cheeseBook = [[Book alloc] init];\r\ncheeseBook.title = @\"Cheese recipes\";\r\ncheeseBook.price = @9000;\r\ncheeseBook.id = @1;\r\n\r\n// Updating book with id = 1\r\n[realm beginWriteTransaction];\r\n[Book createOrUpdateInRealm:realm withValue:cheeseBook];\r\n[realm commitWriteTransaction];\r\n```\r\nWhen I try and change the values of the cheeseBook.title it appears to assert saying that I need to do it between a write and commit transaction.\r\n\r\nIs there a quick way to copy over the previous values and only change the values that I would need to change? i.e\r\nI don't want to write a function for this. Any cues? \r\n\r\n```objective-c\r\n\r\n// Creating a book with the same primary key as a previously saved book\r\nBook *cheeseBook = [[Book previousValues:olderCheeseBook]];\r\n// id is copied over\r\ncheeseBook.price = @1000;\r\n\r\n// Updating book with id = 1\r\n[realm beginWriteTransaction];\r\n[Book createOrUpdateInRealm:realm withValue:cheeseBook];\r\n[realm commitWriteTransaction];\r\n```"},"comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/105683928","html_url":"https://github.com/realm/realm-cocoa/issues/1992#issuecomment-105683928","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1992","id":105683928,"user":{"login":"ArEnSc","id":6252325,"avatar_url":"https://avatars.githubusercontent.com/u/6252325?v=3","gravatar_id":"","url":"https://api.github.com/users/ArEnSc","html_url":"https://github.com/ArEnSc","followers_url":"https://api.github.com/users/ArEnSc/followers","following_url":"https://api.github.com/users/ArEnSc/following{/other_user}","gists_url":"https://api.github.com/users/ArEnSc/gists{/gist_id}","starred_url":"https://api.github.com/users/ArEnSc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArEnSc/subscriptions","organizations_url":"https://api.github.com/users/ArEnSc/orgs","repos_url":"https://api.github.com/users/ArEnSc/repos","events_url":"https://api.github.com/users/ArEnSc/events{/privacy}","received_events_url":"https://api.github.com/users/ArEnSc/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T22:11:03Z","updated_at":"2015-05-26T22:11:03Z","body":"https://github.com/ArEnSc/RealmBug\r\n\r\nSo there are 4 cases outlined in the app code above.\r\n\r\nCase 1: Everything works as expected.\r\n\r\nCase 2: Using [RLMObject initWithValue:persistedObject] works and allows me to copy the references over to the parent object\r\n\r\nCase 3: Adding in the children causes thread access assert when using [RLMObject initWithValue:persistedObject] Perhaps there is a special way to use this if children are included in the mix?  \r\n\r\nCase 4: Referencing children from another object causes thread access assert which makes sense sorta and could be related to case 3.\r\n\r\nRepo\r\nhttps://github.com/ArEnSc/RealmBug\r\n\r\n"}}