DefaultVehicleProvider
public class DefaultVehicleProvider : VehicleProvider
Provides a thread-safe implementation of the VehicleProvider.
Provides the option to update a vehicle or specified vehicle properties and to subscribe to property changes.
Important
This is a Public Preview API. It may be changed or removed at any time.-
Initializes default vehicle provider.
Declaration
Swift
public init( vehicle: Vehicle = Car(combustionEngine: CombustionEngine()) )Parameters
vehicleThe current vehicle to be provided. If not specified the default value is
CarwithCombustionEngine.
-
Setting a different vehicle notifies observers of the latest vehicle state and updated properties. To update only specific properties of the current vehicle, see
TomTomSDKVehicle/VehicleProvider/updateVehicle(with:). All vehicle updates must be done on the main queue.Declaration
Swift
public var vehicle: Vehicle { get set } -
Updates the specific properties of the current vehicle.
Throws
VehicleError.invalidVehicleProperty, if the vehiclepropertiesare not valid for the current vehicle type.Updating vehicle properties notifies observers of the latest vehicle state and updated properties. To set a new vehicle, use
TomTomSDKVehicle/VehicleProvider/vehicle. All vehicle updates must be done on the main queue.Declaration
Swift
public func updateVehicle(with properties: [VehicleProperty]) throwsParameters
propertiesThe vehicle properties to update.
-
Adds a
TomTomSDKVehicle/VehicleUpdateObservertoDefaultVehicleProvider. The call is expected on the main queue. The system keeps a weak reference to the observer.Declaration
Swift
public func addObserver(_ observer: some VehicleUpdateObserver)Parameters
observerA class that can handle vehicle update events.
-
Removes the
TomTomSDKVehicle/VehicleUpdateObserverfromDefaultVehicleProvider. There is no need to unregister the observer. If the observer is not removed, the system will clean up when the next event is posted. The call is expected on the main queue. Do not call this method from the deinitializer of the observer, unless you are certain that the observer will be destroyed on the main queue.Declaration
Swift
public func removeObserver(_ observer: some VehicleUpdateObserver)Parameters
observerA class that can handle vehicle update events.
DefaultVehicleProvider Class Reference