Giter Club home page Giter Club logo

cetableviewbinding's Introduction

##ReactiveCocoa TableView Binding Helper

This project contains a simple helper class that can be used to bind array properties on ReactiveCocoa view models to table views. Here's a quick example of how to use it:

// create a cell template
UINib *nib = [UINib nibWithNibName:@"CETweetTableViewCell" bundle:nil];

// bind the ViewModels 'searchResults' property to a table view
[CETableViewBindingHelper
     bindingHelperForTableView:self.searchResultsTable
                  sourceSignal:RACObserve(self.viewModel, searchResults)
              selectionCommand:nil
                  templateCell:nib];

In the above example, the nib CETweetTableViewCell defines a UITableViewCell subclass which is used for rendering the items within the array. This cell must implement the CEReactiveView protocol.

The binding helper binds a source signal, which is a signal constructed from the array property of the view model, to a UITableView. As a result, the table view will render the contents of the array using the given cell template. Updates to the array property on the view model are automatically be propagated.

If you need to handle selection, you can supply a RACCommand to the binding helper via the selectionCommand argument. This command is executed each time selection changes.

If you need to mutate (i.e. add / remove items) the array property of the view model, use the CEObservableMutableArray class. This is an NSMutableArray subclass that informs observers of mutations, allowing the binding helper to add / remove rows from the table view automatically. See the QuotesListExample project for an example of binding to mutable arrays.

This project contains two example projects:

  • TwitterSearchExample - An example app that searches twitter, with a table view, bound using the helper, displaying the results.
  • QuotesListExample - An example app that shows a list of stock quotes, where prices are dynamically updated and items are added / removed.

To learn more about this helper, see the following blog posts:

cetableviewbinding's People

Contributors

colineberhardt avatar thibault-carpentier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.