From 00bf5716a3ab16ac9d97310701bffc1549b07856 Mon Sep 17 00:00:00 2001 From: Mark Woollard Date: Sat, 23 Jan 2016 18:51:10 +0000 Subject: [PATCH 01/42] Rx wrapper for UITableViewDelegate tableView:accessoryButtonTappedForRowWithIndexPath: method --- RxCocoa/iOS/UITableView+Rx.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/RxCocoa/iOS/UITableView+Rx.swift b/RxCocoa/iOS/UITableView+Rx.swift index 678bda59..e5c78bfb 100644 --- a/RxCocoa/iOS/UITableView+Rx.swift +++ b/RxCocoa/iOS/UITableView+Rx.swift @@ -148,6 +148,18 @@ extension UITableView { return ControlEvent(events: source) } + /** + Reactive wrapper for `delegate` message `tableView:accessoryButtonTappedForRowWithIndexPath:`. + */ + public var rx_itemAccessoryButtonTapped: ControlEvent { + let source: Observable = rx_delegate.observe("tableView:accessoryButtonTappedForRowWithIndexPath:") + .map { a in + return a[1] as! NSIndexPath + } + + return ControlEvent(events: source) + } + /** Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`. */ From 53e9845cb85a3465a794b114a33d0023c5376fef Mon Sep 17 00:00:00 2001 From: Mark Woollard Date: Sat, 23 Jan 2016 19:52:06 +0000 Subject: [PATCH 02/42] Add use of rx_itemAccessoryButtonTapped to simple table view example --- ...SimpleTableViewExampleViewController.swift | 8 ++ RxExample/RxExample/iOS/Main.storyboard | 124 +++++++++--------- 2 files changed, 70 insertions(+), 62 deletions(-) diff --git a/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift b/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift index 4b1b093f..33206ed0 100644 --- a/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift +++ b/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift @@ -38,5 +38,13 @@ class SimpleTableViewExampleViewController : ViewController { DefaultWireframe.presentAlert("Tapped `\(value)`") } .addDisposableTo(disposeBag) + + tableView + .rx_itemAccessoryButtonTapped + .subscribeNext { indexPath in + DefaultWireframe.presentAlert("Tapped Detail @ \(indexPath.section),\(indexPath.row)") + } + .addDisposableTo(disposeBag) + } } \ No newline at end of file diff --git a/RxExample/RxExample/iOS/Main.storyboard b/RxExample/RxExample/iOS/Main.storyboard index e07bb2d6..90608a43 100644 --- a/RxExample/RxExample/iOS/Main.storyboard +++ b/RxExample/RxExample/iOS/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -40,7 +40,7 @@ - + @@ -51,13 +51,13 @@ - -