views:

39

answers:

1

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];
        }
A: 

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.

Jordan
okay I see that redundancy for the array. I got rid of that. The data is coming through and updating, the item I add does appear on the tableview after add is sent to the mysql server and it comes back to the app and get saved. The problem is that the [self.tableview reloaddata] breaks the drill down process and reloads the parent view.
Michael Robinson
[self.tableView reloadData] doesn't break anything. All it does is call the UITableViews delegate method UITableView cellForRowAtIndexPath. If the parent view is getting reload it is because the datasource for the UITableView hasn't been changed. Meaning, the array that you load the UITableView with hasn't changed, or is empty. You need to focus on the array that you use to load the UITableView in the cellForRowAtIndexPath and step through the values to see if the data is what you need.
Jordan
I just added a coule logs to double check the self.tabledatasource3 (it is and is updated) , in the process I noticed that it doesn't matter if I'm updating the data or relaunching the app, if the [self tableview.reloadData] is in there, the drill down doesn't work.
Michael Robinson
I moved this to a viewWillAppear, crashing in a different way, here's the new question:http://stackoverflow.com/questions/3945842/self-tableview-reloaddata-causing-crash-in-uitableview
Michael Robinson