views:

67

answers:

2

I'm getting this crash when selecting a row: '-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (1)',

I moved the data out of the viewWillAppear because we though it was causing a crash. I now have it loading on ViewDidLoad.

However if the [self.tableview reloadData]; is on, I get this crash.

Ideas?

  -(void) loadData3;{

    MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];
NSLog(@"AppDelegate.data3 : %@",AppDelegate.data3 );
NSLog(@"self.tableDataSource3 : %@",self.tableDataSource3 );

}

- (void)viewDidLoad {
    [super viewDidLoad]; 
    [self loadData3];
    if(CurrentLevel3 == 0) {
    self.navigationItem.title = @"Families I Follow";
}
else 
    self.navigationItem.title = CurrentTitle3;  
}
}


-(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear: animated];
            [self.tableview reloadData];
}
A: 

Since its happening while selecting a row, the error is most likely in your tableView:didSelectRowAtIndexPath: or tableView:willSelectRowAtIndexPath: method(s). Nothing seems intrinsically wrong with the viewWillAppear: code fragment that you've posted.

Jeethu
A: 

More than likely, you are changing the Array that loads the UITableView while it is being displayed, so when you click on a Row the row no longer exists in the Array. Therefore, the out of bounds error on the Array.

Jordan
that makes sense. I thought if I had the getdata within the viewWillAppear that it would get it after an update. Now to figure out where to put it.
Michael Robinson
It sounds like you're trying to use the same data Array to populate a parent and child UITableViews. This is incorrect. Either create a new data Array, or make a copy of the current Array.
Jordan
It's a basic drill down NSDictionary, If you take out the reload, everything works and drills down. I don't need a new one, just a refreshed one with the new data that was just downloaded and saved to the phone. Thanks for your time one this, I appreciate it.
Michael Robinson
Not sure I or any one else can help without seeing e code. If you want to zip it and put it somewhere I can take a look.
Jordan
I am trying the NSURLconnection process.
Michael Robinson