Tableview datasource not recognized

Discussion in 'Mac Programming' started by hervey, Sep 29, 2009.

  1. hervey macrumors newbie

    Joined:
    Sep 23, 2009
    #1
    Data from SQLite database is valid until - tableview cellForRowAtIndexPath. I've stripped down the code to it most basic, and still don't see the problem. Connections are made in IB, and data shows on console. Obviously I'm new to Cocoa/Obj C.

    Code in:

    -(UITableViewCell *)tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mad:"TableViewCell"];
    if (cell =nil) {
    cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero
    reuseIdentifier: @"TableViewCell"] autorelease];
    }
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [cities objectAtIndex:row];
    return cell ;
    }

    Error msg:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
    2009-09-29 19:14:25.537 testAER[9939:20b]
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    That's a bug. It should be equality test (==), not assignment (=).
     
  3. hervey thread starter macrumors newbie

    Joined:
    Sep 23, 2009
    #3
    chown33 -

    Thanks! I could have stared at that for another day and missed it. Good eye!

    What's with the emoticons appearing in the text. I didn't place them there, knowingly.

    Cheers,

    - Herv
     
  4. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #4
    You need to enclose your code with
    Code:
     tags otherwise the forum will try to interpret the various parens, brackets, etc.
     

Share This Page