diff --git a/BeeKit/Model/BeeminderModel.xcdatamodeld/BeeminderModel.xcdatamodel/contents b/BeeKit/Model/BeeminderModel.xcdatamodeld/BeeminderModel.xcdatamodel/contents
index 6a3c2b7d..bb7a3f1c 100644
--- a/BeeKit/Model/BeeminderModel.xcdatamodeld/BeeminderModel.xcdatamodel/contents
+++ b/BeeKit/Model/BeeminderModel.xcdatamodeld/BeeminderModel.xcdatamodel/contents
@@ -14,7 +14,7 @@
-
+
diff --git a/BeeKit/Model/DueBy/DueByDictionary.swift b/BeeKit/Model/DueBy/DueByDictionary.swift
index 49cae5a0..ab8ef980 100644
--- a/BeeKit/Model/DueBy/DueByDictionary.swift
+++ b/BeeKit/Model/DueBy/DueByDictionary.swift
@@ -1,4 +1,15 @@
// Part of BeeSwift. Copyright Beeminder
+import SwiftyJSON
+
/// Delta and Total due by YYYYMMDD daystamp
-public typealias DueByDictionary = [String: BeeminderDueByEntry]
+public typealias DueByDictionary = [String: DueByEntry]
+
+extension DueByDictionary {
+ /// Creates a DueByDictionary from SwiftyJSON
+ /// - Parameter json: JSON object containing due by data
+ /// - Returns: Dictionary mapping daystamps to DueByEntry objects
+ public init(json: JSON) {
+ self = json.dictionaryValue.compactMapValues(DueByEntry.init)
+ }
+}
diff --git a/BeeKit/Model/DueBy/BeeminderDueByEntry.swift b/BeeKit/Model/DueBy/DueByEntry.swift
similarity index 93%
rename from BeeKit/Model/DueBy/BeeminderDueByEntry.swift
rename to BeeKit/Model/DueBy/DueByEntry.swift
index 7f341ba8..7914576e 100644
--- a/BeeKit/Model/DueBy/BeeminderDueByEntry.swift
+++ b/BeeKit/Model/DueBy/DueByEntry.swift
@@ -2,8 +2,8 @@
import SwiftyJSON
-@objc(BeeminderDueByEntry)
-public class BeeminderDueByEntry: NSObject, Codable {
+@objc(DueByEntry)
+public class DueByEntry: NSObject, Codable {
public let total: Double
public let delta: Double
public let formattedTotal: String
diff --git a/BeeKit/Model/Goal.swift b/BeeKit/Model/Goal.swift
index 9f9d9c9d..a6273df5 100644
--- a/BeeKit/Model/Goal.swift
+++ b/BeeKit/Model/Goal.swift
@@ -63,7 +63,7 @@ public class Goal: NSManagedObject {
@objc(removeRecentData:)
@NSManaged public func removeFromRecentData(_ values: Set)
- @NSManaged public var dueByDaystamp: DueByDictionary
+ @NSManaged public var dueBy: DueByDictionary
/// The last time this record in the CoreData store was updated
@NSManaged public var lastModifiedLocal: Date
@@ -173,7 +173,7 @@ public class Goal: NSManagedObject {
self.useDefaults = json["use_defaults"].boolValue
self.won = json["won"].boolValue
self.yAxis = json["yaxis"].stringValue
- self.dueByDaystamp = json["dueby"].dictionaryValue.compactMapValues(BeeminderDueByEntry.init)
+ self.dueBy = DueByDictionary(json: json["dueby"])
// Replace recent data with results from server
// Note at present this leaks data points in the main db. This is probably fine for now
diff --git a/BeeSwift.xcodeproj/project.pbxproj b/BeeSwift.xcodeproj/project.pbxproj
index 883352c6..9e8b994b 100644
--- a/BeeSwift.xcodeproj/project.pbxproj
+++ b/BeeSwift.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 54;
+ objectVersion = 70;
objects = {
/* Begin PBXBuildFile section */
diff --git a/BeeSwift/GoalViewController.swift b/BeeSwift/GoalViewController.swift
index e64a9bf8..dd561d95 100644
--- a/BeeSwift/GoalViewController.swift
+++ b/BeeSwift/GoalViewController.swift
@@ -534,7 +534,7 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
self.datapointTableController.hhmmformat = goal.hhmmFormat
self.datapointTableController.datapoints = goal.recentData.sorted(by: {$0.updatedAt < $1.updatedAt})
- self.deltasLabel.isHidden = goal.dueByDaystamp.isEmpty
+ self.deltasLabel.isHidden = goal.dueBy.isEmpty
self.deltasLabel.attributedText = self.dueByTableAttributedString
self.refreshCountdown()
@@ -681,7 +681,7 @@ private extension GoalViewController {
private extension GoalViewController {
var dueByTableAttributedString: NSAttributedString {
- let textAndColor: [(text: String, color: UIColor)] = goal.dueByDaystamp
+ let textAndColor: [(text: String, color: UIColor)] = goal.dueBy
.sorted(using: SortDescriptor(\.key))
.compactMap { $0.value.formattedDelta }
.map { $0 == "✔" ? "✓" : $0 }