title: Strategy for core data sales register
body: <p>I have been trying to use a second managed object context (MOC) in core data to add sales which will be listed in an NSTableView as pending, until the user presses a button to process the transactions. </p>
  
  <p>Upon pressing the button, the 2nd context is saved, and the NSManagedObjectContextDidSaveNotification does trigger mergeChangesFromContextDidSaveNotification on the main context.</p>
  
  <p>So far OK. But, next I need to clear the second context so that the following sale transaction is on a blank MOC. Also to clear it by a cancel action or change of user.</p>
  
  <p>Seems that the clearing of the second MOC is not possible... and I have become convinced after searching for a solution that this is not an viable core data pattern. Instead I am now backtracking to use only one context. However, the current sale now displays all transactions, where I would only want the current ones. Again, if I could list the current "pending" transactions there, have a "cancel" button to undo these if necessary; and clear the table after the "process sale" button, would achieve similar means of managing the transactions. </p>
  
  <p>So I am now stuck since there is no obvious way to identify "current" / pending transactions from other recent ones. </p>
  
  <p>I need a two step data entry. (1) add sales, edit, etc. (2) process i.e. commit these sales</p>
  
  <p>So the first strategy now seems in principle OK and is suggested by  ( <a href="http://developer.apple.com/library/mac/#documentation/DataManagement/Devpedia-CoreData/managedObjectContext.html" rel="nofollow">http://developer.apple.com/library/mac/#documentation/DataManagement/Devpedia-CoreData/managedObjectContext.html</a> )  and also in this tutorial ( <a href="http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/" rel="nofollow">http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/</a> )</p>
  
  <p>Yet the method used in that tutorial only keeps a single managed object in the 2nd context and copies / deletes as required. </p>
  
  <p>Is the best strategy to use the first approach with a second MOC, and copy &amp; delete the transactions rather than merge ? </p>
  
  <p>Or is there a simpler solution that I am not seeing yet ?</p>
  
  <p>Hope this question makes sense :-) and any help appreciated</p>