Skip to content

Commit

Permalink
Adding missing critical properties to appropriate NSCoding/NSCopying/…
Browse files Browse the repository at this point in the history
…isEqual methods.
  • Loading branch information
Jerrad Thramer committed Nov 8, 2017
1 parent 70a74fb commit 0232a6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion MapboxDirections/MBRouteOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ open class RouteOptions: NSObject, NSSecureCoding, NSCopying{
locale = decoder.decodeObject(of: NSLocale.self, forKey: "locale") as Locale?

includesSpokenInstructions = decoder.decodeBool(forKey: "includesSpokenInstructions")

guard let distanceMeasurementSystem = MeasurementSystem(description: decoder.decodeObject(of: NSString.self, forKey: "distanceMeasurementSystem") as String? ?? "") else {
return nil
}
self.distanceMeasurementSystem = distanceMeasurementSystem
}

open static var supportsSecureCoding = true
Expand All @@ -244,6 +249,7 @@ open class RouteOptions: NSObject, NSSecureCoding, NSCopying{
coder.encode(includesExitRoundaboutManeuver, forKey: "includesExitRoundaboutManeuver")
coder.encode(locale, forKey: "locale")
coder.encode(includesSpokenInstructions, forKey: "includesSpokenInstructions")
coder.encode(distanceMeasurementSystem.description, forKey: "distanceMeasurementSystem")
}

// MARK: Specifying the Path of the Route
Expand Down Expand Up @@ -471,6 +477,7 @@ open class RouteOptions: NSObject, NSSecureCoding, NSCopying{
copy.includesExitRoundaboutManeuver = includesExitRoundaboutManeuver
copy.locale = locale
copy.includesSpokenInstructions = includesSpokenInstructions
copy.distanceMeasurementSystem = distanceMeasurementSystem
return copy
}

Expand All @@ -492,7 +499,8 @@ open class RouteOptions: NSObject, NSSecureCoding, NSCopying{
attributeOptions == other.attributeOptions,
includesExitRoundaboutManeuver == other.includesExitRoundaboutManeuver,
locale == other.locale,
includesSpokenInstructions == other.includesSpokenInstructions else { return false }
includesSpokenInstructions == other.includesSpokenInstructions,
distanceMeasurementSystem == other.distanceMeasurementSystem else { return false }
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions MapboxDirectionsTests/RouteOptionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private extension RouteOptions {
opts.attributeOptions = [.congestionLevel]
opts.includesExitRoundaboutManeuver = true
opts.includesSpokenInstructions = true
opts.distanceMeasurementSystem = .metric

return opts
}
Expand Down

0 comments on commit 0232a6f

Please sign in to comment.