title: How to update iOS 10 today widget extension with data from host app?
body: <p>I have looked at Apple's documentation and searched a lot, but I can't find any code or specific explanation on how to do this.</p>
  
  <p>I want to send data to the widget when users open a specific viewController and then update the widget's view to show the new data.</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>Adding a notification. (Did not fire in widget code when posted from app)</li>
  <li>Having a singleton object in the app and update a property, and fetch data from the widget. (This partially works, but the widget is never updated)</li>
  </ol>
  
  <p>I have handled updating the view in the widget, but this is not called when I want to update the widget (changed some values because of company secrets):</p>
  
  <pre><code>- (void) widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
  NSDictionary *data = [[SINGLETON sharedInstance] getData];
  
  if(_data == nil &amp;&amp; data == nil) {
      _showData = NO;
      completionHandler(NCUpdateResultNoData);
  } else if(_data != nil &amp;&amp; [_data isEqual:data]) {
      _showData = YES;
      completionHandler(NCUpdateResultNoData);
  } else if(data == nil) {
      _data = nil;
      _showData = NO;
      [self updateView];
      completionHandler(NCUpdateResultNewData);
  } else {
      _data = data;
      _showData = YES;
      [self updateView];
      completionHandler(NCUpdateResultNewData);
  }
  }
  </code></pre>
  
  <p>[self updateView] is updating the widget's view based on _showData (two different views, one that shows data and one without any data).</p>
  
  <p>Can someone please provide me a simple code example (both app and widget) on how to send data to widget (from host app viewController) and how to update widget's view when data is sent / received?</p>