Skip to content

Commit

Permalink
For some key values, crash instead of using default
Browse files Browse the repository at this point in the history
  • Loading branch information
theospears committed Aug 1, 2024
1 parent b6095fc commit 67f1cf7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion BeeKit/Model/DataPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class DataPoint: NSManagedObject, DataPointProtocol {
/// Produce a DataPoint matching the supplied JSON, either creating a new one or re-using an existing object in the datastore
public static func fromJSON(context: NSManagedObjectContext, goal: Goal, json: JSON) -> DataPoint {
// Check for an existing datapoint with the relevant ID, if so use it
let id = json["id"].stringValue
let id = json["id"].string!

let fetchRequest = NSFetchRequest<DataPoint>(entityName: "DataPoint")
fetchRequest.predicate = NSPredicate(format: "id == %@", id)
Expand Down
4 changes: 2 additions & 2 deletions BeeKit/Model/Goal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class Goal: NSManagedObject, GoalProtocol {
let entity = NSEntityDescription.entity(forEntityName: "Goal", in: context)!
super.init(entity: entity, insertInto: context)
self.owner = owner
self.id = json["id"].stringValue
self.id = json["id"].string!

self.updateToMatch(json: json)
}
Expand All @@ -143,7 +143,7 @@ public class Goal: NSManagedObject, GoalProtocol {

// Question: Should this type know about JSON, or should there be an adapter / extension?
public func updateToMatch(json: JSON) {
self.slug = json["slug"].stringValue
self.slug = json["slug"].string!

self.alertStart = json["alertstart"].intValue
self.autodata = json["autodata"].string
Expand Down

0 comments on commit 67f1cf7

Please sign in to comment.