I am copying an array from first viewcontroller to second viewcontroller by adding the code in viewdidappear in firstviewcontroller.
secondViewController *xyzVC = [[ContactViewController alloc]initWithNibName:@"firstvc" bundle:nil];
xyzVC.arr = self.tableData;
NSLog(@"tabledata %@",tableData);
NSLog(@"arrdata %@",xyzVC.arr);
the arr data is getting the data same as tabledata. but when i use it in the secondviewcontroller i am getting null value as arr data.In second viewcontroller i had imported firstviewcontroller.h and written the code in secondviewcontroller.h file
@property (strong, nonatomic)NSMutableArray *arr;
and in .mfile
i am using the arr in the tableview.If i am alloc init the arr i am getting null data,if not then the same result.i need to alloc init or not and if yes the previous data will gets overwrites?I am new to ios programming help me out.
(NULL)on the other side it's because you're using a different copy of your second VC -- doing another alloc/init of the VC elsewhere. If you're getting an empty array()it's because you're somehow emptying the array (in the first VC) after passing it.