Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用reactivecocoa实现UICollectionViewDataSource方法_Ios_Objective C_Uicollectionview_Reactive Cocoa - Fatal编程技术网

Ios 使用reactivecocoa实现UICollectionViewDataSource方法

Ios 使用reactivecocoa实现UICollectionViewDataSource方法,ios,objective-c,uicollectionview,reactive-cocoa,Ios,Objective C,Uicollectionview,Reactive Cocoa,我正在尝试学习RAC,我已经了解了如何使用RAC\u signalForSelector实现委托方法。我正在使用UICollectionView来显示一些数据,并且我已经使用此解决方案处理了所有必要的UICollectionViewDelegate方法。例如,下面是一个集合视图:didSelectItemAtIndexPath:实现: [[weakSelf rac_signalForSelector:@selector(collectionView:didSelectItemAtIndexPat

我正在尝试学习RAC,我已经了解了如何使用
RAC\u signalForSelector
实现委托方法。我正在使用
UICollectionView
来显示一些数据,并且我已经使用此解决方案处理了所有必要的
UICollectionViewDelegate
方法。例如,下面是一个
集合视图:didSelectItemAtIndexPath:
实现:

[[weakSelf rac_signalForSelector:@selector(collectionView:didSelectItemAtIndexPath:) fromProtocol:@protocol(UICollectionViewDelegate)] subscribeNext:^(RACTuple *arguments) {
        __strong MainViewController *strongSelf = weakSelf;
        NSIndexPath *indexPath = arguments.second;
        DetailViewModel *viewModel = [[DetailViewModel alloc] initWithModel:strongSelf.viewModel.model[indexPath.item]];
        DetailViewController *viewController = [[DetailViewController alloc] initWithViewModel:viewModel];
        [strongSelf.navigationController pushViewController:viewController animated:YES];
}];

我想知道是否有可能实现像这样的
UICollectionViewDataSource
方法,因为它们也有返回值

简短的回答-

反应式Cocoa是一个反应式框架,您应该以反应式而非主动式的方式设计应用程序逻辑。这意味着你应该对某些事件做出反应,并对此采取行动。
例如,用户单击一个单元格,您会得到一个RAC事件,您可以操作该事件(映射、筛选、与其他事件组合等)


这是不可能的,因为Reactive Cocoa是为基于推送的API设计的,用于组合和转换值流。

我在这里问过类似的问题