ForeignMemberContainerClass
public protocol ForeignMemberContainerClass : AnyObject
A class that can contain foreign members in arbitrary keys.
When subclassing ForeignMemberContainerClass
type, you should call decodeForeignMembers(notKeyedBy:with:)
during your Decodable.init(from:)
initializer if your subclass has added any new properties.
Structures should conform to the ForeignMemberContainer
protocol instead of this protocol.
-
Foreign members to round-trip to JSON.
Foreign members are unrecognized properties, similar to foreign members in GeoJSON. This library does not officially support any property that is documented as a “beta” property in the Mapbox Directions API response format, but you can get and set it as an element of this
JSONObject
.Declaration
Swift
var foreignMembers: JSONObject { get set }
-
decodeForeignMembers(notKeyedBy:with:)
Default implementationDecodes any foreign members using the given decoder.
Default Implementation
Declaration
Swift
func decodeForeignMembers<WellKnownCodingKeys>(notKeyedBy codingKeys: WellKnownCodingKeys.Type, with decoder: Decoder) throws where WellKnownCodingKeys : CaseIterable, WellKnownCodingKeys : CodingKey
Parameters
codingKeys
CodingKeys
type which describes all properties declared in current subclass.decoder
Decoder
instance, which perfroms the decoding process. -
encodeForeignMembers(to:)
Default implementationEncodes any foreign members using the given encoder.
This method should be called in your
Encodable.encode(to:)
implementation only in the base class. Otherwise it will not encodeforeignMembers
or way overwrite it.Default Implementation
Declaration
Swift
func encodeForeignMembers(to encoder: Encoder) throws
Parameters
encoder
Encoder
instance, performing the encoding process.