title: Updating a presenting view controller's property inside the modal view controller
body: <p>I was wondering how I would be able to update a view controller <code>property</code> of the presenting view controller from a method called inside the modal view controller? Right now, the only way I could think of is using <code>NSNotificationCenter</code>, and while this works for Dictionary items, I couldn't figure out how to use it for a custom object.</p>
  
  <p>For example, my presenting view controller <code>HomewViewController</code> has a Parse <code>PFObject</code> called <code>homeSelections</code>, which the could be updated in the modally presented <code>ModalViewController</code>'s property <code>newSelections</code> (and also a <code>PFObject</code>) . After the user makes her selections, I would like <code>HomeViewController</code>'s <code>homeSelections</code> to also have the latest data passed from the modal view controller. </p>
  
  <p>Help is appreciated - thanks.</p>
  
  <p><strong>Update 1</strong>: here is what I have done now (note that I am using a stripped down example to test things out)</p>
  
  <p>In <code>ViewController</code> (this is the parent/presenting view controller)</p>
  
  <pre><code>@interface ViewController ()
  
  @property (strong, nonatomic) NSArray *totalRamen;
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      self.totalRamen = @[@"ramen1", @"ramen2", @"ramen3", @"moot"];
  
  }
  
  - (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
      NSLog(@"self.totalRamen: %@", self.totalRamen);
      NSLog(@"Done");
  }
  
  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
      if ([segue.identifier isEqualToString:@"showModal"]){
          ModalViewController *destinationVC = (ModalViewController *)segue.destinationViewController;
          destinationVC.passedRamen = self.totalRamen;
      }
  }
  
  - (IBAction)showModalAction:(UIButton *)sender
  {
      ModalViewController *destinaionViewController = [[ModalViewController alloc] init];
      destinaionViewController.selectionCallback = ^(id selectedItem) {
          self.totalRamen = (NSArray *)selectedItem;
          NSLog(@"self.totalRAmen %@", self.totalRamen);
          NSLog(@"done");
      };
      [self performSegueWithIdentifier:@"showModal" sender:self];
  }
  </code></pre>
  
  <p>In <code>ModalViewController</code> (this is the presented/modal view controller)</p>
  
  <pre><code>@interface ModalViewController : UIViewController
  
  @property (strong, nonatomic) NSArray *passedRamen;
  - (IBAction)dismissModal:(UIButton *)sender;
  
  typedef void(^CallbackBlock)(id value);
  @property (nonatomic, copy) CallbackBlock selectionCallback;
  
  @end
  
  - (void)viewWillAppear:(BOOL)animated{
      [super viewWillAppear:animated];
  
      NSLog(@"Passed ramen %@", self.passedRamen);
      NSLog(@"Done");
  
      self.passedRamen = @[@"moot is awesome"];
      NSLog(@"new ramen: %@", self.passedRamen);
      NSLog(@"%@", self.selectionCallback); //nil here
  
      //call back
      CallbackBlock selectionCallback = self.selectionCallback;
      if (selectionCallback){
          selectionCallback(self.passedRamen); //I want to send the newly updated self.passedRamen back
      } else {
          NSLog(@"No show"); //Means if isn't called
      }
  }
  
  - (IBAction)dismissModal:(UIButton *)sender
  {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  </code></pre>