title: update viewcontroller from appdelegate - best practice?
body: <p>I am playing around with iBeacons implementing CoreLocation methods inside AppDelegate.swift (methods are implemented in AppDelegate to ensure App Background Capabilities)</p>
  
  <p>In a SingleView application that comes with "ViewController.swift", what would be the best practice to pass data from AppDelegate to ViewController to update Views, say UIImages, UILabels or UITableViews ?</p>
  
  <p>I have successfully implemented two different approaches:</p>
  
  <p>1) Delegation, by firing Viewcontroller Delegation methods inside AppDelegate.swift:</p>
  
  <pre><code>protocol BeaconLocationDelegate { func minorBeaconChanged(minorValue:NSNumber) }
  
  var locationDelegate: BeaconLocationDelegate
  
  locationDelegate?.minorBeaconChanged(nearestBeacon.minor)
  </code></pre>
  
  <p>ViewController.swift:</p>
  
  <p>in viewDidLoad method:</p>
  
  <pre><code>(UIApplication.sharedApplication().delegate as AppDelegate).locationDelegate = self
  </code></pre>
  
  <p>(I find this to look rather ugly - any better way to declare this property as delegate?)</p>
  
  <p>protocol implementation:</p>
  
  <pre><code>func minorBeaconChanged(minorValue: NSNumber) {
    // do fancy stuff here
  }
  </code></pre>
  
  <p>2) By creating a reference to ViewController inside AppDelegate:</p>
  
  <pre><code>let viewController:ViewController = window!.rootViewController as ViewController
  viewController.doSomethingFancy()
  </code></pre>
  
  <p>Both approaches work fine for me, but I think the first approach via delegation is more elegant and the better choice once you have multiple ViewControllers.</p>
  
  <p>Any recommendations?</p>