Skip to content

Instantly share code, notes, and snippets.

@tmdvs
Created May 25, 2012 10:49
Show Gist options
  • Select an option

  • Save tmdvs/2787274 to your computer and use it in GitHub Desktop.

Select an option

Save tmdvs/2787274 to your computer and use it in GitHub Desktop.

Revisions

  1. Tim Davies renamed this gist May 25, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Tim Davies created this gist May 25, 2012.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    What Apple gives you and will cause a crash as dequeueReusableCellWithIdentifier: can't return a cell as none have ever been initialised.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    return cell;
    }


    What should be there by default for the app to run

    - (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] autorelease];

    return cell;
    }