title: Fixing delay in Core Data Storage
body: <p>So I am building in a hide function into my application. In my settings menu I have a <code>UISwitch</code> that should allow the user to hide themselves. I have created the <code>UISwitch</code>'s IBAction like so:</p>
  
  <pre><code>-(IBAction)hideUserToggle:(id)sender {
  
      AppDelegate *newAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
      NSManagedObjectContext *context = [newAppDelegate managedObjectContext];
      NSManagedObject *newOwner;
      NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"LoggedInUser" inManagedObjectContext:context];
      NSFetchRequest *request = [[NSFetchRequest alloc] init];
      [request setEntity:entityDesc];
  
      NSManagedObject *matches = nil;
      NSError *error;
      NSArray *objects = [context executeFetchRequest:request error:&amp;error];
  
      newOwner = [NSEntityDescription insertNewObjectForEntityForName:@"LoggedInUser" inManagedObjectContext:context];
  
      if (_hideUser.on) {
  
          if ([objects count] == 0) {
  
              NSLog(@"%@",[error localizedDescription]);
          } else {
  
              matches = objects[0];
              [newOwner setValue:@"userHidden" forKeyPath:@"isHidden"];
              NSLog(@"%@",[matches valueForKeyPath:@"isHidden"]);
          }
      } else {
  
          if([objects count] == 0) {
  
              NSLog(@"%@",[error localizedDescription]);
          } else {
  
              matches = objects[0];
              [newOwner setValue:@"userNotHidden" forKeyPath:@"isHidden"];
              NSLog(@"%@",[matches valueForKeyPath:@"isHidden"]);
          }
      }
  }
  </code></pre>
  
  <p>This should set the value of the Core Data String that I use to determine whether a person is hidden or not, which I use later in my code as a conditional for loading data. However when I test this feature it doesn't seem to update the persistent data store (Core Data) when the user has flipped the switch. I have looked around everywhere and I found a reference to there being a delay in updating Core Data here -> <a href="https://stackoverflow.com/questions/9789697/why-does-ios-delay-when-saving-core-data-via-a-uimanageddocument">Why does IOS delay when saving core data via a UIManagedDocument</a>, however it doesn't seem to provide the answer to my problem. </p>
  
  <p>I want to be able flip the switch and save that value so that when the user swipes over to another view controller it is immediately aware that the user has gone into "hiding" or offline so it does not show certain information.</p>