{"action":"created","issue":{"url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/564","labels_url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/564/labels{/name}","comments_url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/564/comments","events_url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/564/events","html_url":"https://github.com/robbiehanson/XMPPFramework/issues/564","id":96309471,"number":564,"title":"Saving to both managedObjectContext and mainThreadManagedObjectContext","user":{"login":"vondiplo","id":1870445,"avatar_url":"https://avatars.githubusercontent.com/u/1870445?v=3","gravatar_id":"","url":"https://api.github.com/users/vondiplo","html_url":"https://github.com/vondiplo","followers_url":"https://api.github.com/users/vondiplo/followers","following_url":"https://api.github.com/users/vondiplo/following{/other_user}","gists_url":"https://api.github.com/users/vondiplo/gists{/gist_id}","starred_url":"https://api.github.com/users/vondiplo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vondiplo/subscriptions","organizations_url":"https://api.github.com/users/vondiplo/orgs","repos_url":"https://api.github.com/users/vondiplo/repos","events_url":"https://api.github.com/users/vondiplo/events{/privacy}","received_events_url":"https://api.github.com/users/vondiplo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-21T12:59:44Z","updated_at":"2015-07-21T17:41:51Z","closed_at":null,"body":"Hello,\r\n\r\nIn my app I've created my own custom module to handle roster information, save them as my own datatype and allow expending of the built in XMPPUserCoreDataStorageObject. \r\n\r\nMy module works asynchronously on its own thread and builds up the user object.\r\nWhen I want to fetch users I simplify this and fetch them directly from mainThreadManagedObjectContext. Now assume I wish to rename a user. I fetch it from the main thread context, and then changed a the value of the nickname property. In the meanwhile the user itself has changed on server (perhaps changed his nickname) and I receive this information via roster update. \r\n\r\nNow to my question, I have two different versions of the same instance, each on a different context and in a different thread. How do I merge them? Merely setting MergePolicy doesn't have an influence. Moreover, what context do I save to the DB? the mainThreadManagedObjectContext or the the thread dependent? \r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/comments/123412476","html_url":"https://github.com/robbiehanson/XMPPFramework/issues/564#issuecomment-123412476","issue_url":"https://api.github.com/repos/robbiehanson/XMPPFramework/issues/564","id":123412476,"user":{"login":"vondiplo","id":1870445,"avatar_url":"https://avatars.githubusercontent.com/u/1870445?v=3","gravatar_id":"","url":"https://api.github.com/users/vondiplo","html_url":"https://github.com/vondiplo","followers_url":"https://api.github.com/users/vondiplo/followers","following_url":"https://api.github.com/users/vondiplo/following{/other_user}","gists_url":"https://api.github.com/users/vondiplo/gists{/gist_id}","starred_url":"https://api.github.com/users/vondiplo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vondiplo/subscriptions","organizations_url":"https://api.github.com/users/vondiplo/orgs","repos_url":"https://api.github.com/users/vondiplo/repos","events_url":"https://api.github.com/users/vondiplo/events{/privacy}","received_events_url":"https://api.github.com/users/vondiplo/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T17:41:51Z","updated_at":"2015-07-21T17:41:51Z","body":"Based on example used by the xmppframework, I notice that none of the object class has any reference to NSManagedObjectContext. Instead it seems as though the pattern is to hold a storage class for each NSManagedObject (my custom roster for example).\r\n\r\nHow would I go about updating my entities then? Directly through the storage classes or somehow through the entity itself? If I understand correctly, I shouldn't just go around modifying properties of objects returned via mainThreadManagedObjectContext, I should manage the change somehow.\r\n\r\nThank you very much for your patience and help"}}