Search code examples
iosswiftcore-locationsirikitintents-extension

Create custom CLPlacemark for RideIntent


I'm trying to create a custom CLPlacemark using the Intents framework. I'm importing 'Intents' at files beginning.

I found this solution:

let waypointLocation = CLLocation(latitude: 50.00, longitude: 8.00)
let waypointName = "Some Name"

let w1 = CLPlacemark.init(location: waypointLocation,
                                      name: waypointName,
                                      postalAddress: nil)

Unfortunately the above code gives me the following error message:

Ambiguous reference to member 'init(placemark:)'

Any ideas what's wrong?

Documentation:


Solution

  • By subclassing CLPlacemark it is possible to use the Intents frameworks protocol init(location:name:postalAddress).

    Somewhere in your project:

    class MyPlacemark: CLPlacemark {}
    

    Your code to create a custom CLPlacemark:

    let placeLocation = CLLocation(latitude: 50.00, longitude: 8.00)
    let placeName = "Some name"
    let customPlacemark = MyPlacemark(location: w1Location, name: w1Name, postalAddress: nil)