Andrei S Andrei S - 3 months ago 7
Objective-C Question

UITableView reload data

i'm making a navigation based application for iphone.

one of my view controllers looks like this:

@interface NewComputerViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>


so i'm using a
UITableView
to show data.

when the view loads, I use a button in the top navigation bar to run a function
loadStuff
load some stuff in a Dictionary.

My question: how do I repopulate the table view in that viewcontroller from that
loadStuff
function (which belongs to the view controller)

Answer

You can always use [tableView reloadData] method!

But if you have some data stored locally and loading new stuff from some server then you can go for:

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*];
[tableView endUpdates];

And if you want to delete existing row you can use

[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*];
[tableView endUpdates];
Comments