VehicleProvider
public protocol VehicleProvider : AnyObject
Responsible for control, access and notification of the vehicle state.
-
Setting a different vehicle notifies observers of the latest vehicle state. To update only specific properties of the current vehicle, see
TomTomSDKVehicle/VehicleProvider/updateVehicleProperties(_:)
.Declaration
Swift
var vehicle: any Vehicle { get set }
-
Updates the specific properties of the current vehicle.
Throws
An error if the vehicleproperties
are not valid for the current vehicle type.Updating vehicle properties notifies observers of the latest vehicle state. To set a new vehicle, use
TomTomSDKVehicle/VehicleProvider/vehicle
.Declaration
Swift
func updateVehicleProperties(_ properties: [VehicleProperty]) throws
Parameters
properties
The vehicle properties to update.
-
Adds a
TomTomSDKVehicle/VehicleUpdateObserver
toVehicleProvider
. The system keeps a weak reference to the observer.Declaration
Swift
func addVehicleUpdateObserver(_ observer: VehicleUpdateObserver)
Parameters
observer
A class that can handle vehicle update events.
-
Removes the
TomTomSDKVehicle/VehicleUpdateObserver
fromVehicleProvider
. There is no need to remove the observer. If the observer is not removed, the system will clean up when the next event is posted.Declaration
Swift
func removeVehicleUpdateObserver(_ observer: VehicleUpdateObserver)
Parameters
observer
A class that can handle vehicle update events.