Created
September 9, 2012 18:51
-
-
Save tlehman/3686424 to your computer and use it in GitHub Desktop.
Minimal UITableView datasource skeleton (with data)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FizzBuzz | |
| def initialize | |
| @data = (1..100).map { |n| | |
| out = ((n%3 == 0) ? "Fizz" : "") + ((n%5 == 0) ? "Buzz" : "") | |
| (out == "") ? n.to_s : out | |
| } | |
| end | |
| def tableView(tableView, cellForRowAtIndexPath: indexPath) | |
| @reuse_identifier ||= "CELL_IDENTIFIER" | |
| # return a UITableViewCell for the row | |
| cell = tableView.dequeueReusableCellWithIdentifier(@reuse_identifier) || begin | |
| UITableViewCell.alloc.initWithStyle(UITableViewStylePlain, reuseIdentifier:@reuse_identifier) | |
| end | |
| # populate the cell | |
| cell.textLabel.text = @data[indexPath.row].to_s | |
| return cell | |
| end | |
| def tableView(tableView, numberOfRowsInSection: section) | |
| # return the number of rows | |
| return @data.length | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment