title: iOS How to differentiate between changes to underlying data from outside vs from within the class
body: <p>I am having a conceptual issue which I am not sure there is a solution for - tracing the origin of data change.</p>
  
  <p>For example, in my app I have a preferences class that writes settings to user defaults, and I have set up a custom observer pattern where any class interested in a change to settings subscribes as an observer, and is notified when the setting changes. Now, if a setting changes online or on another device, the app receives the change, saves it and notifies all observers.</p>
  
  <p>If I make the change within the app by going into the settings and selecting a new value, the settings class receives the change and again notifies all observers.</p>
  
  <p>The problem is, that the way one would handle the change changes based on whether is the change within the class or elsewhere.</p>
  
  <p>For example, let's say I let the user pick languages they would like to support. This is done through a <code>UITableView</code> where the user can add/remove/reorder the languages. The class that handles this is subscribed as an observer of changes to the <code>languages</code> property of settings, so that if I am in the page and data is changed online, the table view gets reloaded and new languages are displayed. However, when I drag the languages into a new order, I save the new order, this fires the change event of which the class is an observer, and so the table view reloads, cutting short the animation of the drag.</p>
  
  <p>In short, when receiving the observer event, I would like to be able to know whether has this change been handled already (such as if it's internal and so I already dragged/inserted/removed a row) or it requires a table view reload.</p>
  
  <p>Is there any pattern, concept or method that I am unaware of which addresses this?</p>
  
  <p>(By the way I am writing this in Swift 4 for a universal iOS app if that makes any difference)</p>
  
  <p>Thanks</p>