title: Update Apple Watch from multiple ViewControllers with information from UserDefaults
body: <p>I have an application where the user can update the same <code>UserDefaults</code> key in multiple ViewControllers. What I want to do is notify the Apple Watch everytime the information gets updated in one of the three ViewControllers and update it with the new values.</p>
  
  <p>Here is how I'm doing it which I think is not the best way. As you can see I'm duplicating code in all three viewControllers. </p>
  
  <p>What would the best way to update the Apple Watch from multiple ViewControllers?</p>
  
  <h3>Delegate Class</h3>
  
  <pre><code>class AppDelegate: UIResponder, UIApplicationDelegate {  
      var window: UIWindow?
      var canPurchase:Bool = false
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool {
      // Instantiate singleton for sharing the WCSession between viewControllers
      WatchSessionManager.sharedManager.startSession()
      }
  }
  </code></pre>
  
  <h3>View Controller 1:</h3>
  
  <pre><code>class ViewController1: UIViewController{
      func upDateUserDefaults(){
          /// Update UserDefaults...
          sendInfoToAppleWatch()
      }
  
      func sendInfoToAppleWatch(){      
          /// Read UserDefaults
          let message:String = UserDefaults.standard.string(forKey: "messageKey")!
  
          /// Send message to Apple Watch with value from UserDefatults
          let session =  WatchSessionManager.sharedManager.session
          if session.isWatchAppInstalled &amp;&amp; session.isPaired{
              WatchSessionManager.sharedManager.sendAgeToWatch(userMessage: message!)
          }
      }
  }
  </code></pre>
  
  <h3>View Controller 2:</h3>
  
  <pre><code>class ViewController2: UIViewController{
      func upDateUserDefaults(){
          /// Update UserDefaults...
          sendInfoToAppleWatch()
      }
  
      func sendInfoToAppleWatch(){      
          /// Read UserDefaults
          let message:String = UserDefaults.standard.string(forKey: "messageKey")!
  
          /// Send message to Apple Watch with value from UserDefatults
          let session =  WatchSessionManager.sharedManager.session
          if session.isWatchAppInstalled &amp;&amp; session.isPaired{
              WatchSessionManager.sharedManager.sendAgeToWatch(userMessage: message!)
          }
      }
  }
  </code></pre>
  
  <h3>View Controller 3:</h3>
  
  <pre><code>class ViewController3: UIViewController{
      func upDateUserDefaults(){
          /// Update UserDefaults...
          sendInfoToAppleWatch()
      }
  
      func sendInfoToAppleWatch(){      
          /// Read UserDefaults
          let message:String = UserDefaults.standard.string(forKey: "messageKey")!
  
          /// Send message to Apple Watch with value from UserDefatults
          let session =  WatchSessionManager.sharedManager.session
          if session.isWatchAppInstalled &amp;&amp; session.isPaired{
              WatchSessionManager.sharedManager.sendAgeToWatch(userMessage: message!)
          }
      }
  }
  </code></pre>