I have a problem with loading data to UITableView.
My implementation is following:
@interface FirstViewController : UINavigationController <UIActionSheetDelegate, UITableViewDelegate> {
UITableViewController *tableViewController;
UITableView *table;
}
@end
And viewDidLoad method is:
- (void)viewDidLoad {
[super viewDidLoad];
tableViewController = [[UITableViewController alloc] init];
table = [[UITableView alloc] init];
tableViewController.tableView = table;
[tableViewController.tableView setDelegate:self];
self.newsList = [NSMutableArray array];
tableViewController.tableView.rowHeight = 130.0;
[self addObserver:self forKeyPath:@"newsList" options:0 context:NULL];
[self pushViewController:tableViewController animated:NO];
}
And I’m can’t understand what’s wrong. May be data won’t load because i’m adding observer ?
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
[tableViewController.tableView reloadData];
}
Thanks for any advise !
You might’ve forgotten one little thing,
dataSource.Add this after the
setDelegate:method.