views:

36

answers:

2

hey, when my application loads i have a table view which shows data present in my database. On clicking the add button it goes to another view and the data inserted is updated in the database. Now how do i load this updated data when i return from this view to the first view.

Which method do i need to call? ViewDidAppear? or ViewWillAppear? and how do i reset the entire table view n reload the data?

A: 

In viewWillAppear: call [self.tableView reloadData].

Tom Irving
hey thanks for your reply, but it doesnt work. it doesnt show my updated table rather it shows the old table along with the new entry added as a new row in table view
You may need to reload your data set as well then.
Tom Irving
A: 

You can update the rows yourself by calling

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

This will give you the option to have the new row(s) appear in the tableview animated

http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/insertRowsAtIndexPaths:withRowAnimation:

Liam