diff --git a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift index b4769879..a082117e 100644 --- a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift +++ b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift @@ -23,10 +23,12 @@ extension UITableView { O.E == [Section] > (dataSource: DataSource) - (source: O) + -> (source: O) -> Disposable { - let differences = source.differentiateForSectionedView() - return self.rx_itemsWithDataSource(dataSource)(source: differences) + return { source in + let differences = source.differentiateForSectionedView() + return self.rx_itemsWithDataSource(dataSource)(source: differences) + } } } @@ -40,9 +42,11 @@ extension UICollectionView { O.E == [Section] > (dataSource: DataSource) - (source: O) + -> (source: O) -> Disposable { - let differences = source.differentiateForSectionedView() - return self.rx_itemsWithDataSource(dataSource)(source: differences) + return { source in + let differences = source.differentiateForSectionedView() + return self.rx_itemsWithDataSource(dataSource)(source: differences) + } } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift index 0a319ca1..cb286844 100644 --- a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift +++ b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift @@ -12,7 +12,7 @@ public struct AnimatableSectionModel : Hashable , AnimatableSectionModelType , CustomStringConvertible { - public typealias Item = IdentitifiableValue + public typealias Item = IdentifiableValue public typealias Identity = Section public var model: Section @@ -25,7 +25,7 @@ public struct AnimatableSectionModel public init(model: Section, items: [ItemType]) { self.model = model - self.items = items.map(IdentitifiableValue.init) + self.items = items.map(IdentifiableValue.init) } public init(original: AnimatableSectionModel, items: [Item]) { diff --git a/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift b/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift index aad0f405..c069d000 100644 --- a/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift +++ b/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift @@ -11,7 +11,7 @@ import Foundation public protocol AnimatableSectionModelType : SectionModelType , IdentifiableType { - typealias Item : IdentifiableType, Equatable + associatedtype Item : IdentifiableType, Equatable init(original: Self, items: [Item]) } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift index 6e65c031..ee35fbac 100644 --- a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift @@ -8,9 +8,7 @@ import Foundation import UIKit -#if !RX_NO_MODULE - import RxCocoa -#endif +import RxCocoa public class _CollectionViewSectionedDataSource : NSObject @@ -144,13 +142,18 @@ public class CollectionViewSectionedDataSource } override func _collectionView(collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool { - return canMoveItemAtIndexPath?(self, indexPath: indexPath) ?? - super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + guard let canMoveItem = canMoveItemAtIndexPath?(self, indexPath: indexPath) else { + return super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + } + + return canMoveItem } override func _collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) { - return moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) ?? + guard let _ = moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) else { super._collectionView(collectionView, moveItemAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath) + return + } } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/IdentifiableType.swift b/RxExample/RxDataSources/DataSources/IdentifiableType.swift index b5efe3aa..9bda0689 100644 --- a/RxExample/RxDataSources/DataSources/IdentifiableType.swift +++ b/RxExample/RxDataSources/DataSources/IdentifiableType.swift @@ -9,7 +9,7 @@ import Foundation public protocol IdentifiableType { - typealias Identity: Hashable + associatedtype Identity: Hashable var identity : Identity { get } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/IdentifiableValue.swift b/RxExample/RxDataSources/DataSources/IdentifiableValue.swift index ded89cc0..b6ab1385 100644 --- a/RxExample/RxDataSources/DataSources/IdentifiableValue.swift +++ b/RxExample/RxDataSources/DataSources/IdentifiableValue.swift @@ -8,7 +8,7 @@ import Foundation -public struct IdentitifiableValue +public struct IdentifiableValue : IdentifiableType , Equatable , CustomStringConvertible @@ -30,6 +30,6 @@ public struct IdentitifiableValue } } -public func == (lhs: IdentitifiableValue, rhs: IdentitifiableValue) -> Bool { +public func == (lhs: IdentifiableValue, rhs: IdentifiableValue) -> Bool { return lhs.value == rhs.value } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift index d50c4fc7..1723f559 100644 --- a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift @@ -8,9 +8,7 @@ import Foundation import UIKit -#if !RX_NO_MODULE - import RxCocoa -#endif +import RxCocoa // objc monkey business public class _TableViewSectionedDataSource @@ -179,22 +177,35 @@ public class RxTableViewSectionedDataSource } override func _tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { - return canEditRowAtIndexPath?(self, indexPath: indexPath) ?? - super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + guard let canEditRow = canEditRowAtIndexPath?(self, indexPath: indexPath) else { + return super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + } + + return canEditRow } override func _tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { - return canMoveRowAtIndexPath?(self, indexPath: indexPath) ?? - super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + guard let canMoveRow = canMoveRowAtIndexPath?(self, indexPath: indexPath) else { + return super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + } + + return canMoveRow } override func _sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { - return sectionIndexTitles?(self) ?? super._sectionIndexTitlesForTableView(tableView) + guard let titles = sectionIndexTitles?(self) else { + return super._sectionIndexTitlesForTableView(tableView) + } + + return titles } override func _tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { - return sectionForSectionIndexTitle?(self, title: title, index: index) ?? - super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + guard let section = sectionForSectionIndexTitle?(self, title: title, index: index) else { + return super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + } + + return section } } diff --git a/RxExample/RxExample/Example.swift b/RxExample/RxExample/Example.swift index 2b9a810d..2f728caf 100644 --- a/RxExample/RxExample/Example.swift +++ b/RxExample/RxExample/Example.swift @@ -19,7 +19,7 @@ import Foundation let MB = 1024 * 1024 -func exampleError(error: String, location: String = "\(__FILE__):\(__LINE__)") -> NSError { +func exampleError(error: String, location: String = "\(#file):\(#line)") -> NSError { return NSError(domain: "ExampleError", code: -1, userInfo: [NSLocalizedDescriptionKey: "\(location): \(error)"]) } diff --git a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift index e3b834ec..4f021f75 100644 --- a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift +++ b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift @@ -202,7 +202,7 @@ extension GitHubSearchRepositoriesAPI { let range = m.rangeAtIndex(rangeIndex) let startIndex = links.startIndex.advancedBy(range.location) let endIndex = startIndex.advancedBy(range.length) - let stringRange = Range(start: startIndex, end: endIndex) + let stringRange = startIndex ..< endIndex return links.substringWithRange(stringRange) } diff --git a/RxExample/RxExample/Services/Randomizer.swift b/RxExample/RxExample/Services/Randomizer.swift index 24cb5282..2afd271a 100644 --- a/RxExample/RxExample/Services/Randomizer.swift +++ b/RxExample/RxExample/Services/Randomizer.swift @@ -74,7 +74,7 @@ class Randomizer { if rng.get_random() % 2 == 0 { let itemIndex = rng.get_random() % (itemCount + 1) if insertItems { - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex) } else { nextUnusedItems.append(unusedValue) @@ -83,14 +83,14 @@ class Randomizer { // update else { if itemCount == 0 { - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: 0) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: 0) continue } let itemIndex = rng.get_random() % itemCount if reloadItems { nextUnusedItems.append(sections[sectionIndex].items.removeAtIndex(itemIndex).value) - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex) } else { diff --git a/RxSwift/Observables/Observable+Debug.swift b/RxSwift/Observables/Observable+Debug.swift index 41da70aa..2aa355c0 100644 --- a/RxSwift/Observables/Observable+Debug.swift +++ b/RxSwift/Observables/Observable+Debug.swift @@ -21,7 +21,7 @@ extension ObservableType { - returns: An observable sequence whose events are printed to standard output. */ @warn_unused_result(message="http://git.io/rxs.uo") - public func debug(identifier: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: String = __FUNCTION__) + public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) -> Observable { return Debug(source: self.asObservable(), identifier: identifier, file: file, line: line, function: function) }