title: iOS - Notification on NSUserDefaults Change When App Is In Background
body: <p>I have two applications that share an app group <code>@"group.edu.tds.poc.shared"</code></p>
  
  <p>Using NSUserDefaults of this app group, I am able to exchange data between the reader app and the writer app.</p>
  
  <hr>
  
  <p>The Writer App writes data to the NSUserDefault</p>
  
  <pre><code>NSUserDefaults *sharedDefaults =
      [[NSUserDefaults alloc] initWithSuiteName:@"group.edu.tds.poc.shared"];
  
      [sharedDefaults setObject:stringToStore forKey:key];
      [sharedDefaults synchronize];
  </code></pre>
  
  <hr>
  
  <p>The Reader App reads the data from the NSUserDefault</p>
  
  <pre><code> NSUserDefaults *sharedDefaults =
      [[NSUserDefaults alloc] initWithSuiteName:@"group.edu.tds.poc.shared"];
      return [sharedDefaults stringForKey:@"key"];
  </code></pre>
  
  <p>I now want the reader app to be notified as soon as the writer app modifies the value for the key. I.e. Can I notify the reader app when the writer app is running in the foreground (Reader app is either running in the background or is not running).</p>
  
  <p>I have implemented the marked solution but with no luck:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1141388/cocoa-notification-on-nsuserdefaults-value-change/1141404#1141404">Cocoa - Notification on NSUserDefaults value change?</a></li>
  <li><a href="https://stackoverflow.com/questions/5714161/nsuserdefaults-and-kvo-issues">NSUserDefaults and KVO issues</a> </li>
  </ul>
  
  <p>Call back only when the Reader App is in foreground state. (Wrote to the Shared Defaults using Reader app)</p>
  
  <hr>
  
  <p>Any idea if this can be achieved? </p>