From c7d9132f347a59bfac6ffec84cbb906546bd2c5f Mon Sep 17 00:00:00 2001 From: Colin Humber Date: Wed, 27 Feb 2019 08:10:08 -0700 Subject: [PATCH 1/3] Pass missing old sections to refresh method. Remove deprecated .swift-version. --- .swift-version | 1 - Static.podspec | 1 + Static/DataSource.swift | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 .swift-version diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 0062ac9..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -5.0.0 diff --git a/Static.podspec b/Static.podspec index fd15dbf..d88783f 100644 --- a/Static.podspec +++ b/Static.podspec @@ -9,6 +9,7 @@ Pod::Spec.new do |spec| spec.author = { 'Venmo' => 'ios@venmo.com', 'Sam Soffes' => 'sam@soff.es' } spec.platform = :ios, '8.0' + spec.swift_version = '4.2' spec.frameworks = 'UIKit' spec.source_files = 'Static/*.{swift,h}' end diff --git a/Static/DataSource.swift b/Static/DataSource.swift index 9e080a6..0df1ca7 100644 --- a/Static/DataSource.swift +++ b/Static/DataSource.swift @@ -28,7 +28,7 @@ public class DataSource: NSObject { public var sections: [Section] { didSet { assert(Thread.isMainThread, "You must access Static.DataSource from the main thread.") - refresh() + refresh(oldSections: oldValue) } } @@ -101,8 +101,8 @@ public class DataSource: NSObject { refresh() } - private func refresh() { - refreshTableSections() + private func refresh(oldSections: [Section]? = nil) { + refreshTableSections(oldSections: oldSections) refreshRegisteredCells() } From 3e705a32dd3a68f47a7a83adafc3f0c4239932d9 Mon Sep 17 00:00:00 2001 From: Colin Humber Date: Wed, 27 Feb 2019 09:04:17 -0700 Subject: [PATCH 2/3] Make reloading sections an array. Fixed section deletion range logic. Hooked up tests. --- Static.xcodeproj/project.pbxproj | 13 +++++++++++++ .../xcshareddata/xcschemes/Example.xcscheme | 10 ++++++++++ Static/DataSource.swift | 9 ++++----- Static/Tests/DataSourceTests.swift | 8 ++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Static.xcodeproj/project.pbxproj b/Static.xcodeproj/project.pbxproj index 1f19afb..d082f8c 100644 --- a/Static.xcodeproj/project.pbxproj +++ b/Static.xcodeproj/project.pbxproj @@ -49,6 +49,13 @@ remoteGlobalIDString = 21826AA91B3F51A100AA9641; remoteInfo = "Static-iOS"; }; + 3B1129252226E5D800B6E06A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 21826AA11B3F51A100AA9641 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 36748D4E1B5034EC0046F207; + remoteInfo = Example; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -242,6 +249,7 @@ ); dependencies = ( 21826AB71B3F51A100AA9641 /* PBXTargetDependency */, + 3B1129262226E5D800B6E06A /* PBXTargetDependency */, ); name = StaticTests; productName = StaticTests; @@ -391,6 +399,11 @@ target = 21826AA91B3F51A100AA9641 /* Static-iOS */; targetProxy = 363129C51B50354E0024E339 /* PBXContainerItemProxy */; }; + 3B1129262226E5D800B6E06A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 36748D4E1B5034EC0046F207 /* Example */; + targetProxy = 3B1129252226E5D800B6E06A /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ diff --git a/Static.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Static.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index 3c4e2b1..204b44d 100644 --- a/Static.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Static.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -28,6 +28,16 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + = start..<(start - delta) + let range: Range = newCount..<(newCount - delta) tableView.deleteSections(IndexSet(integersIn: range), with: animation) } diff --git a/Static/Tests/DataSourceTests.swift b/Static/Tests/DataSourceTests.swift index 67664f5..76b9a3a 100644 --- a/Static/Tests/DataSourceTests.swift +++ b/Static/Tests/DataSourceTests.swift @@ -41,6 +41,14 @@ class DataSourceTests: XCTestCase { XCTAssertEqual(4, tableView.numberOfRows(inSection: 1)) XCTAssertEqual(2, tableView.numberOfRows(inSection: 2)) + dataSource.sections = [ + Section(rows: [Row(text: "Merrily"), Row(text: "Merrily")]), + Section(rows: [Row(text: "Life"), Row(text: "Is"), Row(text: "But"), Row(text: "A"), Row(text: "Dream")]), + ] + XCTAssertEqual(2, tableView.numberOfSections) + XCTAssertEqual(2, tableView.numberOfRows(inSection: 0)) + XCTAssertEqual(5, tableView.numberOfRows(inSection: 1)) + dataSource.sections = [] XCTAssertEqual(0, tableView.numberOfSections) } From 7609dfc7c93365f7d8286003df6d79563e5051d7 Mon Sep 17 00:00:00 2001 From: Colin Humber Date: Tue, 9 Apr 2019 13:31:40 -0600 Subject: [PATCH 3/3] Updated Swift version --- Static.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Static.podspec b/Static.podspec index d88783f..a33d0ca 100644 --- a/Static.podspec +++ b/Static.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |spec| spec.author = { 'Venmo' => 'ios@venmo.com', 'Sam Soffes' => 'sam@soff.es' } spec.platform = :ios, '8.0' - spec.swift_version = '4.2' + spec.swift_version = '5.0' spec.frameworks = 'UIKit' spec.source_files = 'Static/*.{swift,h}' end