Join Scott Gardner for an in-depth discussion in this video Bind collection views: Part 2, part of Reactive Programming in iOS with RxSwift.
- [Voiceover] Next, I'll implement…adding new sections when the addBarButtonItem is tapped.…To do that, I'll use the UIBarButtonItem's…extension rx_tap, which works similarly…to UIButton's rx_tap extension,…and I'll stick with using Driver here, too.…I'll driveNext and, once again,…just create an unowned self capture list…because self cannot be nil here…before the closure is executed in this single view app.…If this were a presented view controller, for example,…I would need to make this a we capture.…
And I'll go ahead and add this…to the disposeBag so they don't forget.…I'll first create a section value…equal to the current count of data.value,…which remember, is a variable of array…of AnimatedSectionModel…Then, I'll create an item's array of String,…and use a closure to set it.…In that closure, I'll create a local item's var,…a random number,…and then append items with a String…for each number from zero up to the random number…to use as my cell's titles.…
And I'll return items.…Finally, I'll set data.value to its current value…
Learn reactive programming with Reactive Extensions for Swift and iOS by following along with author Scott Gardner. Scott introduces the Reactive Extensions libraries for Swift and Cocoa Touch, and shows how to work with observable sequences, bind user interface and data elements, perform networking operations, debug Rx code, and more.
- Using the Reactive Extensions library
- Working with observable sequences
- Binding UI and data elements
- Binding table and collection views
- Error handling