I'm creating the UITableView datasource array using this code:
-(void) viewWillAppear:(BOOL)animated
{
// IBOutlet of tableview is 'editMsgTableView'
editMsgTableView.dataSource=nil;
editMsgTableView.delegate=nil;
menuMessageArray = [[NSMutableArray alloc] init];
editMainMenuMsgArray = [[NSMutableArray alloc] init];
menuMessageArray = [DBManager fetchmenu:0 noOfRows:32];
for(int i=0; i< [menuMessageArray count]; i++)
{
NSMutableDictionary *menuMsgListDic = [[NSMutableDictionary alloc] init];
menuMsgListDic = [menuMessageArray objectAtIndex:i];
[editMainMenuMsgArray addObject:menuMsgListDic];
}
editMsgTableView.dataSource=self;
editMsgTableView.delegate=self;
[editMsgTableView reloadData];
}
But it works for the first time. But whenever I do some tableView editing stuff or comes from another view controller,after that if viewWillAppearis called then reloadData is not working. I also tried:
dispatch_sync(dispatch_get_main_queue(), ^{
[editMsgTableView reloadData];
});
but not working. Please help me out.
datasource&delegateofeditMsgTableVieweach time inviewWillAppear. Instead setdelegateanddatasourceinviewDidLoad. Usedeallocmethod for releasing.