资源算法EPSReactiveList

EPSReactiveList

2020-01-17 | |  30 |   0 |   0

EPSReactiveList

EPSReactiveList provides subclasses of UITableViewController and UICollectionViewController that automatically populate a table/collection view, and animates the insertion and deletion of rows/items by observing changes to an array of model objects. It uses ReactiveCocoa, and is designed to be used with the MVVM pattern.

EPSReactiveList replaces EPSReactiveTableViewController and EPSReactiveCollectionViewController.

Usage

Subclass either EPSReactiveTableViewController or EPSReactiveCollectionViewController, and write an init method which calls setBindingToKeyPath:onObject: to set up the binding. The value at the key path must always be an NSArray containing objects that implement -isEqual: and -hash. No object should appear in the array more than once. In the init method, register a cell class for use with the class of object that will be contained in the observed array. (The cell class must conform to <EPSReactiveListCell>.)

- (id)init {
  self = [super initWithStyle:UITableViewStylePlain];  if (self == nil) return nil;

  _viewModel = [EPSExampleViewModel new];
  [self setBindingToKeyPath:@"sortedNotes" onObject:_viewModel];
  [self registerCellClass:[EPSNoteCell class] forObjectsWithClass:[EPSNote class]];
  ...  return self;
}

To respond to taps on cells, override either -tableView:didSelectRowForObject:atIndexPath: or -collectionView:didSelectItemForObject:atIndexPath:, depending on whether you have subclassed EPSReactiveTableViewController or EPSReactiveCollectionViewController.

- (void)tableView:(UITableView *)tableView didSelectRowForObject:(id)object atIndexPath:(NSIndexPath *)indexPath {  // Do something with `object`}

You don’t need to write any datasource methods.

For more complete examples of how to use EPSReactiveTableViewController and EPSReactiveCollectionViewController, see the example project.

Example Project

To run the example project; clone the repo, and run pod install from the Project directory first.

Requirements

EPSReactiveTableViewController requires ReactiveCocoa 2.3 or higher.

Installation

EPSReactiveList is available through CocoaPods—to install it simply add the following line to your Podfile:

pod "EPSReactiveList"

Alternatively, include the files in the Classes directory in your project, and install ReactiveCocoa 2.3 by following their installation instructions.

License

EPSReactiveList is available under the MIT license. See the LICENSE file for more info.


上一篇:min-char-rnn

下一篇: EPSReactiveTableViewController

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • shih-styletransfer

    shih-styletransfer Code from Style Transfer ...