title: How to reload a table view, after data source (array) being edited by a Modal View controller
body: <p>Hey, I had this question, <a href="https://stackoverflow.com/questions/2097788/uitableview-not-refreshing-after-modal-view-controller-dismisses">UITableView Not refreshing after Modal View Controller dismisses</a></p>
  
  <p>But, I didnt seem to get a straight answer,</p>
  
  <p>Can anyone else shed some light?</p>
  
  <p>Heres the code.</p>
  
  <p>FirstViewController.h</p>
  
  <pre><code>@interface FirstViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; {
  
  NSMutableArray *routines;
  IBOutlet UITableView *myTableView;
  
  }
  
   @property (nonatomic, retain) NSMutableArray *routines;
   @property (nonatomic, retain) UITableView *myTableView;
  
  - (IBAction)showNewEventViewController;   
  </code></pre>
  
  <p>@end</p>
  
  <p>and its .m</p>
  
  <pre><code>#import "FirstViewController.h"
  #import "NewEventViewController.h"
  
  @implementation FirstViewController
  
  @synthesize routines, myTableView;
  
  
  - (void)viewWillAppear:(BOOL)animated{
  [myTableView reloadData];
  NSLog(@"Routines: %@", routines);
  NSLog(@"refreshed!");
  
  for(int i = 0; i &lt; [routines count]; i++){
  
      NSLog(@"%@", [routines objectAtIndex:i]);
  
            }
  
   }  
  
  
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  
  return [routines count];
  
  }
  
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  static NSString *CellIdentifier = @"Cell";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  }
  
  // Set up the cell...
  NSString *cellValue = [routines objectAtIndex:indexPath.row];
  [cell.textLabel setText:cellValue];
  
  return cell;
  }
  
  
  
  - (IBAction)showNewEventViewController {    
  
  NewEventViewController *controller = [[NewEventViewController alloc] initWithNibName:@"NewEventView" bundle:nil];
  controller.routines = routines;
  controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  [self presentModalViewController:controller animated:YES];
  
  [controller release];
  }
  
  
  
  
  - (void)viewDidLoad {
  
  routines = [[NSMutableArray alloc] init];
  
  [routines addObject:@"Hello"];
  [routines addObject:@"Temp"];
  [routines addObject:@"Temp2"];
  [routines addObject:@"Temp3"];
  [routines addObject:@"Temp4"];
  
  
  }
  </code></pre>
  
  <p>and the modal view controllers .h (NewEventViewController.h)</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  
   @interface NewEventViewController : UIViewController {
  
  IBOutlet UITextField *RoutineTitle;
  
  IBOutlet UITextField *RoutineInvolvment;
  
  
  NSMutableArray *routines;
  
  
  }
  
  
  @property(nonatomic, retain)  NSMutableArray *routines;
  
  
  -(IBAction)done;
  
  
  @end
  </code></pre>
  
  <p>and its .h</p>
  
  <pre><code>#import "NewEventViewController.h"
  #import "FirstViewController.h"
  
  
  
  
  @implementation NewEventViewController
  @synthesize routines;
  
  
  -(IBAction)done{
  
  
  
   [routines addObject:RoutineTitle.text]; 
  [self dismissModalViewControllerAnimated:YES];
  NSLog(@"Routines: %@", routines);
  
  }
  </code></pre>