I try adding objects to NSMutableArray from another class (secondViewController) and then add it to my UITableView in my FirstViewController, but it returns null when I print it using NSLog. Here is my set up.
FirstViewController.h:
@interface FirstViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>{
IBOutlet UITableView *mytableview;
NSMutableArray *mytableinfo;
}
@property (nonatomic,retain) IBOutlet UITableView *mytableview;
@property (retain) IBOutlet NSMutableArray *mytableinfo;
FirstViewController.m
#import "FirstViewController.h"
#import "SecondViewController.h"
@synthesize mytableinfo,mytableview;
-(IBAction)addShift:(id)sender{
SecondViewController *secondViewController = [[SecondViewController alloc]init];
[self presentModalViewController:secondViewController animated:YES];
}
- (void)viewDidLoad
{
mytableinfo = [[NSMutableArray alloc]init];
[super viewDidLoad];
}
SecondViewController.m
#import "SecondViewController.h"
#import "FirstViewController.h"
@implementation SecondViewController
@synthesize dateformatter,mydatepicker,startingTime;
-(IBAction)saveShift:(id)sender{
FirstViewController *firstViewController = [[FirstViewController alloc]init];
[firstViewController.mytableinfo addObject:@"Hello world"];
NSLog(@"%@",firstViewController.mytableinfo);
[self dismissModalViewControllerAnimated:YES];
}
My goal is to ultimately feed a mytableview
from mytableinfo
. I'm not even sure if this is the best way to go about it. Any advice would be appreciated.