资源算法 EPSReactiveTableViewController

EPSReactiveTableViewController

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

EPSReactiveTableViewController

⚠️ EPSReactiveTableViewController has been deprecated in favor of EPSReactiveList. ⚠️

EPSReactiveTableViewController is a subclass of UITableViewController that automatically populates a table view, and animates the insertion and deletion of rows by observing changes to an array of model objects. It uses ReactiveCocoa, and is designed to be used with the MVVM pattern.

EPSReactiveCollectionViewController provides similar functionality for collection view controllers.

Usage

Subclass EPSReactiveTableViewController, and write an init method which calls initWithStyle:bindingToKeyPath:onObject: on super 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 <EPSReactiveTableViewCell>.)

- (id)init {
    EPSExampleViewModel *viewModel = [EPSExampleViewModel new];
    self = [super initWithStyle:UITableViewStylePlain bindingToKeyPath:@"sortedObjects" onObject:viewModel];
    [self registerCellClass:[EPSNoteCell class] forObjectsWithClass:[EPSNote class]];
    ...    return self;
}

If you want to know when a cell is tapped on, subscribe to the didSelectRowSignal property.

[self.didSelectRowSignal subscribeNext:^(RACTuple *tuple) {    RACTupleUnpack(id object, NSIndexPath *indexPath, UITableView *tableView) = tuple;    // Do something with `object`}];

You don’t need to write any <UITableViewDataSource> methods.

For a more complete example of how to use EPSReactiveTableViewController, see the example project.

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

Requirements

EPSReactiveTableViewController requires ReactiveCocoa 2.2 or higher.

Installation

EPSReactiveTableViewController is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "EPSReactiveTableViewController"

Alternatively, include EPSReactiveTableViewController.h and EPSReactiveTableViewController.m in your project, and install ReactiveCocoa 2.2 by following their installation instructions.

License

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


上一篇:EPSReactiveList

下一篇:EPSR2017

用户评价
全部评价

热门资源

  • 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 ...