Skip to content

Commit 81f6539

Browse files
committed
Migrate to Swift 4.2
1 parent 03ba730 commit 81f6539

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

ShareClient.xcodeproj/project.pbxproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
TargetAttributes = {
323323
432B0E871CDFC3C50045347B = {
324324
CreatedOnToolsVersion = 7.3.1;
325-
LastSwiftMigration = 0900;
325+
LastSwiftMigration = 1000;
326326
};
327327
432B0E911CDFC3C50045347B = {
328328
CreatedOnToolsVersion = 7.3.1;
@@ -334,6 +334,7 @@
334334
};
335335
43A8EC81210E664300A81379 = {
336336
CreatedOnToolsVersion = 9.4.1;
337+
LastSwiftMigration = 1000;
337338
ProvisioningStyle = Automatic;
338339
};
339340
};
@@ -662,7 +663,7 @@
662663
SKIP_INSTALL = YES;
663664
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchos watchsimulator";
664665
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
665-
SWIFT_VERSION = 4.0;
666+
SWIFT_VERSION = 4.2;
666667
TARGETED_DEVICE_FAMILY = "1,2,4";
667668
};
668669
name = Debug;
@@ -688,7 +689,7 @@
688689
PRODUCT_NAME = "$(TARGET_NAME)";
689690
SKIP_INSTALL = YES;
690691
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchos watchsimulator";
691-
SWIFT_VERSION = 4.0;
692+
SWIFT_VERSION = 4.2;
692693
TARGETED_DEVICE_FAMILY = "1,2,4";
693694
};
694695
name = Release;
@@ -760,7 +761,7 @@
760761
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
761762
SKIP_INSTALL = YES;
762763
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
763-
SWIFT_VERSION = 4.0;
764+
SWIFT_VERSION = 4.2;
764765
TARGETED_DEVICE_FAMILY = "1,2";
765766
};
766767
name = Debug;
@@ -793,7 +794,7 @@
793794
PRODUCT_BUNDLE_IDENTIFIER = com.loopkit.ShareClientUI;
794795
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
795796
SKIP_INSTALL = YES;
796-
SWIFT_VERSION = 4.0;
797+
SWIFT_VERSION = 4.2;
797798
TARGETED_DEVICE_FAMILY = "1,2";
798799
};
799800
name = Release;

ShareClient/ShareClientManager.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ public class ShareClientManager: CGMManager {
7474

7575
// Ignore glucose values that are up to a minute newer than our previous value, to account for possible time shifting in Share data
7676
let startDate = self.cgmManagerDelegate?.startDateToFilterNewData(for: self)?.addingTimeInterval(TimeInterval(minutes: 1))
77-
let newGlucose = glucose.filterDateRange(startDate, nil).filter({ $0.isStateValid }).map {
77+
let newGlucose = glucose.filterDateRange(startDate, nil)
78+
let newSamples = newGlucose.filter({ $0.isStateValid }).map {
7879
return NewGlucoseSample(date: $0.startDate, quantity: $0.quantity, isDisplayOnly: false, syncIdentifier: "\(Int($0.startDate.timeIntervalSince1970))", device: self.device)
7980
}
8081

81-
self.latestBackfill = glucose.first
82+
self.latestBackfill = newGlucose.first
8283

83-
if newGlucose.count > 0 {
84-
completion(.newData(newGlucose))
84+
if newSamples.count > 0 {
85+
completion(.newData(newSamples))
8586
} else {
8687
completion(.noData)
8788
}

ShareClientUI/ShareClientSettingsViewController.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public class ShareClientSettingsViewController: UITableViewController {
3737

3838
title = cgmManager.localizedTitle
3939

40-
tableView.rowHeight = UITableViewAutomaticDimension
40+
tableView.rowHeight = UITableView.automaticDimension
4141
tableView.estimatedRowHeight = 44
4242

43-
tableView.sectionHeaderHeight = UITableViewAutomaticDimension
43+
tableView.sectionHeaderHeight = UITableView.automaticDimension
4444
tableView.estimatedSectionHeaderHeight = 55
4545

4646
tableView.register(SettingsTableViewCell.self, forCellReuseIdentifier: SettingsTableViewCell.className)
@@ -49,32 +49,28 @@ public class ShareClientSettingsViewController: UITableViewController {
4949

5050
// MARK: - UITableViewDataSource
5151

52-
private enum Section: Int {
52+
private enum Section: Int, CaseIterable {
5353
case authentication
5454
case latestReading
5555
case delete
56-
57-
static let count = 3
5856
}
5957

6058
override public func numberOfSections(in tableView: UITableView) -> Int {
61-
return allowsDeletion ? Section.count : Section.count - 1
59+
return allowsDeletion ? Section.allCases.count : Section.allCases.count - 1
6260
}
6361

64-
private enum LatestReadingRow: Int {
62+
private enum LatestReadingRow: Int, CaseIterable {
6563
case glucose
6664
case date
6765
case trend
68-
69-
static let count = 3
7066
}
7167

7268
override public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
7369
switch Section(rawValue: section)! {
7470
case .authentication:
7571
return 1
7672
case .latestReading:
77-
return LatestReadingRow.count
73+
return LatestReadingRow.allCases.count
7874
case .delete:
7975
return 1
8076
}

0 commit comments

Comments
 (0)