title: Creating a copy of a PFObject
body: <p>I am in a situation where I allow the user to download a <code>PFObject</code> and modify it locally, and they can then either cancel the changes or hit Done, which will dismiss the editing interface but NOT upload the changes to Parse yet. They need to hit Save on the previous screen to write all changes to the database at once. </p>
  
  <p>The problem is once the <code>PFObject</code> is modified, you cannot revert it to its prior state without refetching from the database. But I cannot always refetch the data from the database every time they hit Cancel because the prior state may not be uploaded to Parse yet (and that's a bad UX making them wait to discard changes that are only stored locally). </p>
  
  <p>For example, imagine the user taps to edit the <code>PFObject</code>, they make changes then hit Done, then tap on it again and further edit the object, then hit Cancel. In this case, the object needs to be reverted to its prior state, but that state has not been uploaded to Parse yet. So I cannot refetch the data from the database to revert changes otherwise it would overwrite the changes they made the first time.</p>
  
  <p>To solve this problem, I would simply fetch the <code>PFObject</code> and store a copy of it. I'd call that the transient object. I would have another property that stores the real object. The user would modify the transient object, and when they hit Cancel I would simply set that to <code>nil</code>, if they instead hit Done I would set the real object equal to the transient object, and once they finally hit Save I would save the real object to the database. That way I can be sure changes aren't being made to the real object until the user commits the changes. The problem is, <code>PFObject</code> does not adopt the <code>NSCopying</code> protocol (not sure why), therefore I cannot create a copy of the <code>PFObject</code>. Any change I make to it affects the real object.</p>
  
  <p>How can this be resolved, without modifying the app's design that allows control over when the data is committed and later saved? Is there a way to extend <code>PFObject</code> and adopt <code>NSCopying</code>, has it been done before?</p>
  
  <p>I did consider storing the attributes of the object in a dictionary and allow the user to edit that instead, then upon commit set each of those attributes on the <code>PFObject</code>. The problem with this solution arises with complex structures. In this app, I allow the user to modify multiple arrays that contain multiple <code>PFObject</code>s. It's just infeasible to try to recreate and later merge changes with complex structures like this beyond a single simple <code>PFObject</code>.</p>