Skip to content

Commit 8d7fa4e

Browse files
author
Damien Rambout
committed
Fix segmentation faults in Xcode 7.3 (swift 2.2)
1 parent 3b49a19 commit 8d7fa4e

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

Sources/DataSources/CollectionViewSectionedDataSource.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,18 @@ public class CollectionViewSectionedDataSource<S: SectionModelType>
142142
}
143143

144144
override func _collectionView(collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool {
145-
return canMoveItemAtIndexPath?(self, indexPath: indexPath) ??
146-
super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath)
145+
guard let canMoveItem = canMoveItemAtIndexPath?(self, indexPath: indexPath) else {
146+
return super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath)
147+
}
148+
149+
return canMoveItem
147150
}
148151

149152
override func _collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
150-
return moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) ??
153+
guard let _ = moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) else {
151154
super._collectionView(collectionView, moveItemAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath)
155+
return
156+
}
152157
}
153158

154159
}

Sources/DataSources/TableViewSectionedDataSource.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,35 @@ public class RxTableViewSectionedDataSource<S: SectionModelType>
177177
}
178178

179179
override func _tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
180-
return canEditRowAtIndexPath?(self, indexPath: indexPath) ??
181-
super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
180+
guard let canEditRow = canEditRowAtIndexPath?(self, indexPath: indexPath) else {
181+
return super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
182+
}
183+
184+
return canEditRow
182185
}
183186

184187
override func _tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
185-
return canMoveRowAtIndexPath?(self, indexPath: indexPath) ??
186-
super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
188+
guard let canMoveRow = canMoveRowAtIndexPath?(self, indexPath: indexPath) else {
189+
return super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
190+
}
191+
192+
return canMoveRow
187193
}
188194

189195
override func _sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? {
190-
return sectionIndexTitles?(self) ?? super._sectionIndexTitlesForTableView(tableView)
196+
guard let titles = sectionIndexTitles?(self) else {
197+
return super._sectionIndexTitlesForTableView(tableView)
198+
}
199+
200+
return titles
191201
}
192202

193203
override func _tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {
194-
return sectionForSectionIndexTitle?(self, title: title, index: index) ??
195-
super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index)
204+
guard let section = sectionForSectionIndexTitle?(self, title: title, index: index) else {
205+
return super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index)
206+
}
207+
208+
return section
196209
}
197210

198211
}

0 commit comments

Comments
 (0)