12 Mar 2013, 23:11
Photo_44_pragsmall

Martin Trejo (1 post)

Hi,

I’m working on the samples on the book and found that the code sample http://media.pragprog.com/titles/carubym/code/tables/TableFun_basic/app/controllers/alphabet_controller.rb is wrong at line 18.

At the en of the line is missing ‘   begin’ that opens a block.

The code in the book and in the code website have the same issue.

Otherwise the book is excellent for rubyist moving to iOS development.

18 Mar 2013, 23:13
Generic-user-small

Hari Datti Khalsa (2 posts)

Do you mind posting the relevant code (or a gist)? Line 18 is blank when I look at this code sample.

18 Mar 2013, 22:09
Watermark copy 2_test_pragsmall

Clay Allsopp (8 posts)

Hey guys, the code should actually be this:

  def tableView(tableView, cellForRowAtIndexPath: indexPath)
    @reuseIdentifier ||= "CELL_IDENTIFIER"
 
    cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier) || begin
      UITableViewCell.alloc.initWithStyle(
        UITableViewCellStyleDefault,
        reuseIdentifier:@reuseIdentifier)
    end
 
    cell.textLabel.text = @data[indexPath.row]
    cell
  end
18 Mar 2013, 23:14
Generic-user-small

Hari Datti Khalsa (2 posts)

Thanks Clay!

26 Dec 2013, 12:18
Generic-user-small

Bob Follek (1 post)

In the assignment to cell, do you need the begin/end block? It seems like the UITableViewCell.alloc.initWithStyle line can stand alone.

  You must be logged in to comment