Created
June 9, 2014 11:19
-
-
Save sideshowcoder/a18925f3f59b878bdd91 to your computer and use it in GitHub Desktop.
Couchbase as a table view data source
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 ItemsViewController < UIViewController | |
| attr_accessor :database, :user_id, :data_source | |
| def viewDidLoad | |
| super | |
| navigationItem.title = "Items" | |
| @items_table = UITableView.alloc.initWithFrame(view.bounds) | |
| @items_table.delegate = self | |
| @data_source = CBLUITableSource.alloc.init | |
| @data_source.query = Item.queryListsInDatabase(database).asLiveQuery | |
| @data_source.labelProperty = "title" | |
| @data_source.tableView = @items_table | |
| @items_table.dataSource = @data_source | |
| view.addSubview @items_table | |
| end | |
| def couchTableSource source, updateFromQuery:query, previousRows:previousRows | |
| @items_table.reloadData | |
| end | |
| def couchTableSource source, willUseCell:cell, forRow:row | |
| cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment