views:

99

answers:

3

In the following code, I have determined that everything works, up until [tableView reloadData] i have NSLOGs set up in the table view delegate methods and none of them are getting called. I have other methods doing the same reloadData and it works perfectly. The only difference tha I am awayre of is tha this is in a @catch block. maybe you smart guys can see something i'm doing wrong...

@catch (NSException * e) {////chart is user genrated
    logoView.image = nil;
    NSInteger row = [picker selectedRowInComponent:0];
    NSString *selectedAircraft = [aircraft objectAtIndex:row];
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                         NSUserDomainMask, YES);
    NSString *docsPath = [paths objectAtIndex:0];
    NSString *checklistPath = [[NSString alloc]initWithFormat:@"%@/%@.checklist",docsPath,selectedAircraft];
    NSString *dataString = [NSString stringWithContentsOfFile:checklistPath encoding: NSUTF8StringEncoding error:NULL];


    if ([dataString hasPrefix:@"\n"]) {
        dataString = [dataString substringFromIndex:1];
    }
    NSArray *tempArray = [dataString componentsSeparatedByString:@"\n"];

    NSDictionary *temporaryDictionary = [NSDictionary dictionaryWithObject: tempArray forKey:@"User Generated Checklist"];
    self.names = temporaryDictionary;


    NSArray *tempArray2 = [NSArray arrayWithObject:@"01User Generated Checklist"];
    self.keys = tempArray2;
    aircraftLabel.text = selectedAircraft;
    checklistSelectPanel.hidden = YES;
    [tableView reloadData];


}
+1  A: 

You probably don't want to hear this but you didn't specifically mention it so it has to be asked - have you actually set the tableView delegate?

alku83
yes I have. The table view works fine (and reloads) in all the other parts of the code.
Brodie
Fair enough. What about if you move the code to another branch, outside the catch block? Or alternatively, comment out any unnecessary code simply to see if you can get the table to reload? Or manually setting the delegate again just before the reload?
alku83
after some more inspection it seems that the "numberOf SectionsInTableView" and "numberOfRowsInSection" delegate methods ARE working, however the "cellForRowatIndexPath" is NOT. I have an nslog at the the top of that one and that doesnt even get tripped...this section of code is identical to the section that is in the @try block except for where the data is being pulled from.
Brodie
Only thing I can think of then is that there aren't actually any rows to display. That's the only reason I can think why that method wouldn't be called.
alku83
+1  A: 

I ran into this same problem. After tearing my hair out for days on end, I realized that I had set my table as the view (ie my view controller's view property was set to the table), and apparently, that is a no-no.

If your table is your view, make another view, and place the table inside the new view you created. Et voila, your table refreshes.

Brian515
I don't know if this is the solution here, but I find that having a tableview inside your view does offer much more flexibility with adjusting the interface.
Cirrostratus
+1  A: 

"User Generated Checklist" and "01User Generated Checklist"

Brodie