I am super confused.
I have 2 controllers, lets call them controller1 and controller2.
In controller1.m I have this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSString *object = self.objects[indexPath.row];
cell.textLabel.text = [object description];
return cell;
}
and in controller2.m I am trying to reload the tableview in controller1.m:
- (void)GetRequest
{
NSArray *tableData = [dataSource.areaData GetPurchaseOrderItems:[NSString stringWithFormat:@"%@%@",areaPickerSelectionString,unitPickerSelectionString]];
if(!purchaseOrder.objects){
purchaseOrder.objects = [[NSMutableArray alloc]init];
}
for(int i = 0; i < [tableData count]; i++){
[purchaseOrder.objects addObjectsFromArray:[tableData objectAtIndex:i]];
NSLog(@"%@",[tableData objectAtIndex:i]);
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[purchaseOrder.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
NSLog(@"%@", purchaseOrder.objects);
//[self.tableView reloadData];
}
I have tried the following:
controller1.h:
@property(nonatomic, retain) UITableView *tableView;
controller1.m:
@synthesize tableView;
controller2.h:
#import "controller1.h"
@interface controller2 ()
{
controller1 *purchaseOrder;
}
- (void)viewDidLoad {
purchaseOrder = [[controller1 alloc]init];
}
and then [purchaseOrder.tableView reloadData];
and my tableView doesnt get reloaded. WTF ? I have no idea what I am doing wrong here. I also get this warning on:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
and here is the warning:
Local declaration of 'tableView' hides instance variable
purchaseOrder = [[controller1 alloc]init];. This creates a newcontroller1. If you wantpurchaseOrderto update, you need to push or present it first. I suspect you probably already have acontroller1somewhere else but this new one has no relationship to any that might have already been on the screen.