UserLocations
public struct UserLocations
Entity holding all personal locations of the current user of the application.
All modifications to the personal locations must be persisted using PersonalData.storeUserProfile
.
Important
This is a Public Preview API. It may be changed or removed at any time.-
Errors related to
UserLocations
.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public enum Error : Swift.Error
-
The user’s home location.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var home: PersonalLocation? { get }
-
The user’s work location.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var work: PersonalLocation? { get }
-
The user’s favorite locations.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var favorites: [PersonalLocation] { get }
-
The recent destinations of the user, ordered with the most recent one first.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var recentDestinations: [PersonalLocation] { get }
-
Checks whether this place is associated with any personal locations.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public func findLocations(with place: Place) -> [PersonalLocation]
Parameters
place
The place for which to find the personal location.
Return Value
The personal locations matching the given place, an empty array if no such location exists.
-
Find a personal location by its identifier.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public func findLocation(with id: UUID) -> PersonalLocation?
Parameters
id
The identifier of the personal location to find.
Return Value
The personal location for the given id or
nil
if no such location exists. -
Creates a new personal location with the given types. The new personal location is assigned to the respective property of the user locations and returned.
Throws
UserLocations.Error.typesSetIsEmpty
if an empty set of types has been passed.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
@discardableResult public mutating func create( types: Set<PersonalLocation.`Type`>, place: Place, name: String = "", hasPrivateCharger: Bool = false ) throws -> PersonalLocation
Parameters
types
The types of the personal location. Is required to be non-empty, otherwise the method throws a
UserLocations.Error.typesSetIsEmpty
error.place
The place for which a personal location is created.
name
The name of the personal location.
hasPrivateCharger
Whether the personal location has a private charger.
Return Value
The newly created personal location.
-
Updates the given personal location with the new types.
Throws
UserLocations.Error.typesSetIsEmpty
if an empty set of types has been passed.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
@discardableResult public mutating func update( location: PersonalLocation, types: Set<PersonalLocation.`Type`> ) throws -> Bool
Parameters
location
The personal location to update.
types
The new types for the personal location. It is required to be non-empty, otherwise the method throws a
UserLocations.Error.typesSetIsEmpty
.Return Value
True if the location was updated, false if the location was not found.
-
Removes the given personal location.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
@discardableResult public mutating func remove(location: PersonalLocation) -> Bool
Parameters
location
The personal location to remove.
Return Value
True if the location was removed, false if the location was not found.