Skip to content

Instantly share code, notes, and snippets.

@pablasso
Created March 22, 2012 17:05
Show Gist options
  • Save pablasso/2159752 to your computer and use it in GitHub Desktop.
Save pablasso/2159752 to your computer and use it in GitHub Desktop.
Filling a UITableView
// to fill a table you need to implement the protocol UITableViewDataSource in the Header and implement this //methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}
// Also implement this method to return the cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment