Skip to content

Commit 0815630

Browse files
committed
Updates deprecated attributes.
1 parent 4317e70 commit 0815630

File tree

6 files changed

+179
-20
lines changed

6 files changed

+179
-20
lines changed

Example/Base.lproj/Main.storyboard

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,29 @@
1818
<sections>
1919
<tableViewSection id="Qz7-v6-H2v">
2020
<cells>
21-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="lN3-iK-CfR" style="IBUITableViewCellStyleDefault" id="04o-Ht-qxL">
21+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Sgj-7Q-MpH" style="IBUITableViewCellStyleDefault" id="DCT-de-sAU">
2222
<rect key="frame" x="0.0" y="35" width="600" height="44"/>
2323
<autoresizingMask key="autoresizingMask"/>
24+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="DCT-de-sAU" id="AQS-oS-U5w">
25+
<rect key="frame" x="0.0" y="0.0" width="567" height="43.5"/>
26+
<autoresizingMask key="autoresizingMask"/>
27+
<subviews>
28+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Customization using table view delegate" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Sgj-7Q-MpH">
29+
<rect key="frame" x="15" y="0.0" width="550" height="43.5"/>
30+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
31+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
32+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
33+
<nil key="highlightedColor"/>
34+
</label>
35+
</subviews>
36+
</tableViewCellContentView>
37+
<connections>
38+
<segue destination="KDb-mL-3sx" kind="show" id="qbW-7z-TwN"/>
39+
</connections>
40+
</tableViewCell>
41+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="lN3-iK-CfR" style="IBUITableViewCellStyleDefault" id="04o-Ht-qxL">
42+
<rect key="frame" x="0.0" y="79" width="600" height="44"/>
43+
<autoresizingMask key="autoresizingMask"/>
2444
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="04o-Ht-qxL" id="rCL-pV-Obt">
2545
<rect key="frame" x="0.0" y="0.0" width="567" height="43.5"/>
2646
<autoresizingMask key="autoresizingMask"/>
@@ -35,11 +55,11 @@
3555
</subviews>
3656
</tableViewCellContentView>
3757
<connections>
38-
<segue destination="WCh-dm-Kq1" kind="push" id="yE8-75-4re"/>
58+
<segue destination="WCh-dm-Kq1" kind="show" id="c9r-5j-1vm"/>
3959
</connections>
4060
</tableViewCell>
4161
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="cL7-ld-vsF" style="IBUITableViewCellStyleDefault" id="vNm-h9-1nj">
42-
<rect key="frame" x="0.0" y="79" width="600" height="44"/>
62+
<rect key="frame" x="0.0" y="123" width="600" height="44"/>
4363
<autoresizingMask key="autoresizingMask"/>
4464
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vNm-h9-1nj" id="3KB-x6-Bl9">
4565
<rect key="frame" x="0.0" y="0.0" width="567" height="43.5"/>
@@ -55,7 +75,7 @@
5575
</subviews>
5676
</tableViewCellContentView>
5777
<connections>
58-
<segue destination="f4D-bS-ukh" kind="push" id="vUe-QP-Eup"/>
78+
<segue destination="f4D-bS-ukh" kind="show" id="M1P-qR-6Bf"/>
5979
</connections>
6080
</tableViewCell>
6181
</cells>
@@ -72,6 +92,40 @@
7292
</objects>
7393
<point key="canvasLocation" x="351" y="660"/>
7494
</scene>
95+
<!--Customization Using Table View Delegate-->
96+
<scene sceneID="mPx-2r-SJr">
97+
<objects>
98+
<viewController id="KDb-mL-3sx" customClass="CustomizationUsingTableViewDelegate" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
99+
<layoutGuides>
100+
<viewControllerLayoutGuide type="top" id="yCr-cM-Bms"/>
101+
<viewControllerLayoutGuide type="bottom" id="jvS-Am-QIe"/>
102+
</layoutGuides>
103+
<view key="view" contentMode="scaleToFill" id="gZF-1v-OGP">
104+
<rect key="frame" x="0.0" y="64" width="600" height="536"/>
105+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
106+
<subviews>
107+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="hus-v9-hWb">
108+
<rect key="frame" x="0.0" y="0.0" width="600" height="536"/>
109+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
110+
</tableView>
111+
</subviews>
112+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
113+
<constraints>
114+
<constraint firstItem="hus-v9-hWb" firstAttribute="top" secondItem="yCr-cM-Bms" secondAttribute="bottom" id="GTm-fM-rNU"/>
115+
<constraint firstAttribute="trailing" secondItem="hus-v9-hWb" secondAttribute="trailing" id="cB6-62-ajd"/>
116+
<constraint firstItem="jvS-Am-QIe" firstAttribute="top" secondItem="hus-v9-hWb" secondAttribute="bottom" id="phQ-EZ-pOS"/>
117+
<constraint firstItem="hus-v9-hWb" firstAttribute="leading" secondItem="gZF-1v-OGP" secondAttribute="leading" id="zvn-Br-8zA"/>
118+
</constraints>
119+
</view>
120+
<navigationItem key="navigationItem" id="XtM-GE-PWk"/>
121+
<connections>
122+
<outlet property="tableView" destination="hus-v9-hWb" id="qDY-zV-RvK"/>
123+
</connections>
124+
</viewController>
125+
<placeholder placeholderIdentifier="IBFirstResponder" id="lko-2L-UQK" userLabel="First Responder" sceneMemberID="firstResponder"/>
126+
</objects>
127+
<point key="canvasLocation" x="775" y="1430"/>
128+
</scene>
75129
<!--View Controller-->
76130
<scene sceneID="2Ak-6r-Q44">
77131
<objects>
@@ -84,16 +138,12 @@
84138
<rect key="frame" x="0.0" y="64" width="600" height="536"/>
85139
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
86140
<subviews>
87-
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="7zo-oL-ecc">
88-
<rect key="frame" x="0.0" y="0.0" width="198" height="536"/>
89-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
90-
</tableView>
91141
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="0ST-dd-uow">
92-
<rect key="frame" x="198" y="0.0" width="198" height="536"/>
142+
<rect key="frame" x="200" y="0.0" width="199.5" height="536"/>
93143
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
94144
</tableView>
95145
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="8RU-L3-ENh">
96-
<rect key="frame" x="396" y="0.0" width="198" height="536"/>
146+
<rect key="frame" x="399" y="0.0" width="200" height="536"/>
97147
<color key="backgroundColor" red="1" green="0.99997437000274658" blue="0.99999129772186279" alpha="1" colorSpace="calibratedRGB"/>
98148
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="1iM-sR-ecz">
99149
<size key="itemSize" width="50" height="50"/>
@@ -128,11 +178,11 @@
128178
</collectionViewCell>
129179
</cells>
130180
<collectionReusableView key="sectionHeaderView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Section" id="eOG-yl-3U2" customClass="NumberSectionView" customModule="Example" customModuleProvider="target">
131-
<rect key="frame" x="0.0" y="0.0" width="198" height="50"/>
181+
<rect key="frame" x="0.0" y="0.0" width="200" height="50"/>
132182
<autoresizingMask key="autoresizingMask"/>
133183
<subviews>
134184
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ovF-dr-qlS">
135-
<rect key="frame" x="78" y="15" width="42" height="20"/>
185+
<rect key="frame" x="79" y="15" width="42" height="20"/>
136186
<fontDescription key="fontDescription" type="system" pointSize="17"/>
137187
<color key="textColor" red="0.98431372549999996" green="0.98431372549999996" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
138188
<nil key="highlightedColor"/>
@@ -149,6 +199,10 @@
149199
</connections>
150200
</collectionReusableView>
151201
</collectionView>
202+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="7zo-oL-ecc">
203+
<rect key="frame" x="0.0" y="0.0" width="200" height="536"/>
204+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
205+
</tableView>
152206
</subviews>
153207
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
154208
<constraints>
@@ -161,8 +215,8 @@
161215
<constraint firstItem="8RU-L3-ENh" firstAttribute="top" secondItem="tH7-yZ-7T9" secondAttribute="topMargin" constant="44" id="MaZ-iw-wqB"/>
162216
<constraint firstItem="8RU-L3-ENh" firstAttribute="leading" secondItem="0ST-dd-uow" secondAttribute="trailing" id="PZ5-O0-Hxi"/>
163217
<constraint firstItem="0ST-dd-uow" firstAttribute="width" secondItem="7zo-oL-ecc" secondAttribute="width" id="YMa-qV-SVb"/>
164-
<constraint firstItem="7zo-oL-ecc" firstAttribute="width" secondItem="tH7-yZ-7T9" secondAttribute="width" multiplier="0.33" id="czT-Pb-ZCj"/>
165-
<constraint firstItem="7zo-oL-ecc" firstAttribute="leading" secondItem="tH7-yZ-7T9" secondAttribute="leadingMargin" constant="-20" id="nrB-GH-T4i"/>
218+
<constraint firstItem="7zo-oL-ecc" firstAttribute="width" secondItem="tH7-yZ-7T9" secondAttribute="width" multiplier="0.3333" id="czT-Pb-ZCj"/>
219+
<constraint firstItem="7zo-oL-ecc" firstAttribute="leading" secondItem="tH7-yZ-7T9" secondAttribute="leading" id="nrB-GH-T4i"/>
166220
<constraint firstItem="0ST-dd-uow" firstAttribute="top" secondItem="tH7-yZ-7T9" secondAttribute="topMargin" constant="44" id="qfj-UJ-wLI"/>
167221
<constraint firstItem="84O-UE-hUo" firstAttribute="top" secondItem="0ST-dd-uow" secondAttribute="bottom" id="snL-Fx-Qqj"/>
168222
<constraint firstItem="84O-UE-hUo" firstAttribute="top" secondItem="7zo-oL-ecc" secondAttribute="bottom" id="vqD-13-am3"/>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//
2+
// CustomizationUsingTableViewDelegate.swift
3+
// RxDataSources
4+
//
5+
// Created by Krunoslav Zaher on 4/19/16.
6+
// Copyright © 2016 kzaher. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
import RxSwift
12+
import RxCocoa
13+
import RxDataSources
14+
15+
struct MySection {
16+
var header: String
17+
var items: [Item]
18+
}
19+
20+
extension MySection : AnimatableSectionModelType {
21+
typealias Item = Int
22+
23+
var identity: String {
24+
return header
25+
}
26+
27+
init(original: MySection, items: [Item]) {
28+
self = original
29+
self.items = items
30+
}
31+
}
32+
33+
extension Int : IdentifiableType {
34+
public typealias Identity = Int
35+
36+
public var identity : Int {
37+
return self
38+
}
39+
}
40+
41+
class CustomizationUsingTableViewDelegate : UIViewController {
42+
@IBOutlet var tableView: UITableView!
43+
44+
let disposeBag = DisposeBag()
45+
46+
var dataSource: RxTableViewSectionedAnimatedDataSource<MySection>?
47+
48+
override func viewDidLoad() {
49+
super.viewDidLoad()
50+
51+
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
52+
53+
let dataSource = RxTableViewSectionedAnimatedDataSource<MySection>()
54+
55+
dataSource.configureCell = { ds, tv, ip, item in
56+
let cell = tv.dequeueReusableCellWithIdentifier("Cell") ?? UITableViewCell(style: .Default, reuseIdentifier: "Cell")
57+
cell.textLabel?.text = "Item \(item)"
58+
59+
return cell
60+
}
61+
62+
dataSource.titleForHeaderInSection = { ds, index in
63+
return ds.sectionModels[index].header
64+
}
65+
66+
let sections = [
67+
MySection(header: "First section", items: [
68+
1,
69+
2
70+
]),
71+
MySection(header: "Second section", items: [
72+
3,
73+
4
74+
])
75+
]
76+
77+
Observable.just(sections)
78+
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
79+
.addDisposableTo(disposeBag)
80+
81+
tableView.rx_setDelegate(self)
82+
.addDisposableTo(disposeBag)
83+
84+
self.dataSource = dataSource
85+
}
86+
}
87+
88+
extension CustomizationUsingTableViewDelegate : UITableViewDelegate {
89+
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
90+
guard let item = dataSource?.itemAtIndexPath(indexPath) else {
91+
return 0.0
92+
}
93+
94+
return CGFloat(40 + item)
95+
}
96+
}

Example/EditingExampleViewController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EditingExampleViewController: UIViewController {
1717

1818
@IBOutlet weak var tableView: UITableView!
1919
let disposeBag = DisposeBag()
20-
20+
2121
override func viewDidLoad() {
2222
super.viewDidLoad()
2323

@@ -27,7 +27,8 @@ class EditingExampleViewController: UIViewController {
2727
NumberSection(header: "Section 3", numbers: [], updated: NSDate())]
2828

2929
let initialState = SectionedTableViewState(sections: sections)
30-
let addCommand = addButton.rx_tap
30+
let addCommand = Observable.of(addButton.rx_tap.asObservable(), Observable.of((), (), ()))
31+
.merge()
3132
.scan(0) { x, _ in x + 1 }
3233
.map { (number: Int) -> TableViewEditingCommand in
3334
let randSection = Int(arc4random_uniform(UInt32(sections.count)))
@@ -42,7 +43,7 @@ class EditingExampleViewController: UIViewController {
4243
.map { (sourceIndex, destinationIndex) in
4344
return TableViewEditingCommand.MoveItem(sourceIndex: sourceIndex, destinationIndex: destinationIndex)
4445
}
45-
46+
4647
Observable.of(addCommand, deleteCommand, movedCommand)
4748
.merge()
4849
.scan(initialState) {
@@ -53,7 +54,7 @@ class EditingExampleViewController: UIViewController {
5354
$0.sections
5455
}
5556
.shareReplay(1)
56-
.bindTo(tableView.rx_itemsAnimatedWithDataSource(dataSource))
57+
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
5758
.addDisposableTo(disposeBag)
5859

5960
skinTableViewDataSource(dataSource)

Example/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ViewController: UIViewController {
5151
skinTableViewDataSource(reloadDataSource)
5252

5353
randomSections
54-
.bindTo(animatedTableView.rx_itemsAnimatedWithDataSource(tvAnimatedDataSource))
54+
.bindTo(animatedTableView.rx_itemsWithDataSource(tvAnimatedDataSource))
5555
.addDisposableTo(disposeBag)
5656

5757
randomSections
@@ -74,7 +74,7 @@ class ViewController: UIViewController {
7474
skinCollectionViewDataSource(cvAnimatedDataSource)
7575

7676
randomSections
77-
.bindTo(animatedCollectionView.rx_itemsAnimatedWithDataSource(cvAnimatedDataSource))
77+
.bindTo(animatedCollectionView.rx_itemsWithDataSource(cvAnimatedDataSource))
7878
.addDisposableTo(disposeBag)
7979
}
8080
else {

0 commit comments

Comments
 (0)