From e1ec5010d55d12ee471bfa1debc4c5c727533464 Mon Sep 17 00:00:00 2001 From: Ameir Al-Zoubi Date: Sat, 7 Apr 2018 16:12:39 -0400 Subject: [PATCH 1/4] fixes issue when dynamically assigning rows in RadioSection, also fixes equatable compliance of Row protocol --- Source/Model/RadioSection.swift | 2 +- Source/Protocol/Row.swift | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/Model/RadioSection.swift b/Source/Model/RadioSection.swift index d09228f5..f8a76de5 100644 --- a/Source/Model/RadioSection.swift +++ b/Source/Model/RadioSection.swift @@ -49,7 +49,7 @@ open class RadioSection: Section { return options } set { - options = rows as? [OptionRowCompatible] ?? options + options = newValue as? [OptionRowCompatible] ?? options } } diff --git a/Source/Protocol/Row.swift b/Source/Protocol/Row.swift index 236b9d2f..0725b57a 100644 --- a/Source/Protocol/Row.swift +++ b/Source/Protocol/Row.swift @@ -41,11 +41,7 @@ public protocol Row { } -extension Row { - - /// Returns true iff `lhs` and `rhs` have equal titles and subtitles. - public static func == (lhs: Self, rhs: Self) -> Bool { - return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle - } - +/// Returns true iff `lhs` and `rhs` have equal titles and subtitles. +func ==(lhs: Row, rhs: Row) -> Bool { + return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle } From f5a92938fb24eac85bf736dde21c44004def85d4 Mon Sep 17 00:00:00 2001 From: Ameir Al-Zoubi Date: Sun, 8 Apr 2018 07:46:14 -0400 Subject: [PATCH 2/4] fix equatable conformance --- Source/Protocol/Row.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Protocol/Row.swift b/Source/Protocol/Row.swift index 0725b57a..a596439c 100644 --- a/Source/Protocol/Row.swift +++ b/Source/Protocol/Row.swift @@ -40,8 +40,14 @@ public protocol Row { } +extension Row { + /// Returns true iff `lhs` and `rhs` have equal titles and subtitles. + public static func == (lhs: Self, rhs: Self) -> Bool { + return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle + } +} /// Returns true iff `lhs` and `rhs` have equal titles and subtitles. -func ==(lhs: Row, rhs: Row) -> Bool { +public func == (lhs: Row, rhs: Row) -> Bool { return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle } From 3501d3675612e893f84696355324a79279244018 Mon Sep 17 00:00:00 2001 From: Ameir Al-Zoubi Date: Mon, 9 Apr 2018 05:49:20 -0400 Subject: [PATCH 3/4] declare row protocol as class protocol to allow for identity comparison --- Source/Protocol/Row.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Source/Protocol/Row.swift b/Source/Protocol/Row.swift index a596439c..c82451f1 100644 --- a/Source/Protocol/Row.swift +++ b/Source/Protocol/Row.swift @@ -27,27 +27,25 @@ import Foundation /// Any type that conforms to this protocol is capable of representing a row in a table view. -public protocol Row { - +public protocol Row: class { + /// The title text of the row. var title: String { get } - + /// The subtitle text of the row. var subtitle: Subtitle? { get } - + /// A closure related to the action of the row. var action: ((Row) -> Void)? { get } - + } + extension Row { + /// Returns true iff `lhs` and `rhs` have equal titles and subtitles. public static func == (lhs: Self, rhs: Self) -> Bool { return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle } -} - -/// Returns true iff `lhs` and `rhs` have equal titles and subtitles. -public func == (lhs: Row, rhs: Row) -> Bool { - return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle + } From f31d62a539646ed5a08de98ec28d36ecb0f8ec0a Mon Sep 17 00:00:00 2001 From: Ameir Al-Zoubi Date: Mon, 9 Apr 2018 05:52:00 -0400 Subject: [PATCH 4/4] whitespace fix --- Source/Protocol/Row.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Protocol/Row.swift b/Source/Protocol/Row.swift index c82451f1..7916b3ac 100644 --- a/Source/Protocol/Row.swift +++ b/Source/Protocol/Row.swift @@ -28,24 +28,24 @@ import Foundation /// Any type that conforms to this protocol is capable of representing a row in a table view. public protocol Row: class { - + /// The title text of the row. var title: String { get } - + /// The subtitle text of the row. var subtitle: Subtitle? { get } - + /// A closure related to the action of the row. var action: ((Row) -> Void)? { get } - + } extension Row { - + /// Returns true iff `lhs` and `rhs` have equal titles and subtitles. public static func == (lhs: Self, rhs: Self) -> Bool { return lhs.title == rhs.title && lhs.subtitle == rhs.subtitle } - + }