title: User defaults not saving
body: <p>I just built my first app and there is only one thing left to do. I am getting data from a url. If that URL fails or is nil then I would like to get the data from the User Defaults.</p>
  
  <p>I have a function that saves the user defaults from the data off the URL</p>
  
  <pre><code>- (void)saveToUserDefaults
  {
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      [defaults setObject:data forKey:@"data"];
      [defaults synchronize];
  }
  </code></pre>
  
  <p>and here is some more of my code.</p>
  
  <pre><code>NSURL *url = [NSURL URLWithString:@"http://jamessuske.com/isthedomeopen/isthedomeopenGetData.php"];
          data = [NSData dataWithContentsOfURL:url options:0 error:nil];
          [self saveToUserDefaults];
          if(url == nil){
              NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
              data = [defaults dataForKey:@"data"];
          }
          NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
  </code></pre>
  
  <p>I disconnected from the internet and ran my app in a simulator and my app returned empty values.</p>
  
  <p>What can I do to fix this?</p>