0
votes

I have a UITableView that uses JSON to to get new data from the AppDelegate. It saves the data and then is pulled into this tableview class from the AppDelegate.data3, After I add a record to the mysql database I launch the Delegate method that refreshes the data.

However,[self.tableview reLoadData]; breaks the drill down ability of the table, If I select the row, it pushes the child view for a split second and the refreshes the screen with the Parent Rows. If I take out the [self.tableview reLoadData]; The parent pushes to the child but I don't get a refreshed screen with the new data.

Any Ideas?

-(void) loadData3;{

    //Initialize table data source  
    MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];

}
  - (void)viewDidLoad {
    [super viewDidLoad];
    if(CurrentLevel3 == 0) {
        self.navigationItem.title = @"Parent Table";
     }
    else 
        self.navigationItem.title = CurrentTitle3;  
     }
 }
- (void)viewDidAppear:(BOOL)animated {
        [self loadData3];
        [self.tableview reloadData];
            [super viewDidAppear:animated];
        }
1
might try calling [super viewDidAppear:animated] before [self loadData3] - bguest
I don't know if this will fix anything, but I've been using viewWillAppear: instead of viewDidAppear: for this kind of thing. - Nimrod
@nimrod Placing the viewWillAppear caused : ERROR __NSCFArray objectAtIndex:]: index (1) beyond bounds (1)' - Michael Robinson

1 Answers

0
votes

There are several issues. It's not clear what you are trying to do.

You set self.tableDataSource3 to tempArray, and then set it to [AppDelegate.data3 ....];

Why?

     NSArray *tempArray = [[NSArray alloc] init];
     self.tableDataSource3 = tempArray;
      [tempArray release];
    MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];

On Startup [self loadData3] gets called twice. Once in viewDidLoad and viewDidAppear. Unnecessary. Should only be in viewWillAppear.

You're either not saving data that you're adding, or not retrieving it properly. Might have to step through your code to see if you're getting the data you should be getting.