Reputation: 711
I ran into a piece of code for UITableView, click on of the cell and it reloads but what exactly is the data source? I am not too clear on this.
[xTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:button.tag inSection:0],nil] withRowAnimation:UITableViewRowAnimationFade];
Upvotes: 0
Views: 166
Reputation: 21221
DataSource is a protocol in the UITableView that defines a set of messages that the UITableView sends to this object(datasource) These messages returns data that is filled inside the tableview Some messages are like:
numberOfRowsInSection
: you will return the number of rows this table will have
cellForRowAtIndex
: you will return here the UITableViewCell object for the given index
numberOfSectionsInTableView
: you will return the number of sections this table will have
How this works
in your class you will call tableView.dataSource = self;
[UITableView reloadData]
gets executed, the datasource messages get sent to the datasource object (in this example it will be the object set on the right side of .dataSource = self;
table view will use these consecutive calls to build the table view itself
For further indepth reading please rever to
Simple tutorial on how to implement the datasource in iphone
Upvotes: 1
Reputation: 400
It runs the following "tableview cellForRowAtIndexPath" method and loads the updated information for the specified cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Hope it helps.
Upvotes: 2