How to get AGSNMEALocation from AGSNMEALocationDataSource

663
2
Jump to solution
05-10-2021 10:13 AM
WyattHarrell
New Contributor

I am attempting to use the initializer initWithEAAccessory:protocol: and the locationDataSource:locationDidChange: method for the AGSNMEALocationDataSource.

 

 The documentation for AGSNMEALocationDataSource states that “the locationDataSource:locationDidChange: (AGSLocationChangeHandlerDelegate-p) method will return an AGSNMEALocation,” but after conforming to the AGSNMEALocationDataSourceDelegate the method actually returns a AGSLocation instead. 

 

How can I access the AGSNMEALocation?

 

 

class SomeClassName: AGSLocationChangeHandlerDelegate {

    func locationDataSource(_ locationDataSource: AGSLocationDataSource, locationDidChange location: AGSLocation) {

        // This delegate method gives back an AGSLocation instead of the needed AGSNMEALocation as stated in the documentation

    }

}

 

 

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

Hi Wyatt,

You can safely downcast the `AGSLocation` type to `AGSNMEALocation` with

 

```swift

guard let nmeaLocation = location as? AGSNMEALocation else { return }

```

Reason:

The NMEA delegate method inherits from the `AGSLocationChangeHandlerDelegate`... But I'll let our team know that the API design here is a bit confusing, and maybe we can add another `AGSNMEALocation` specific stub in the delegate.

 

References:

- Sample code

- AGSNMEALocation

AGSNMEALocationDataSourceDelegate

View solution in original post

0 Kudos
2 Replies
Ting
by Esri Contributor
Esri Contributor

Hi Wyatt,

You can safely downcast the `AGSLocation` type to `AGSNMEALocation` with

 

```swift

guard let nmeaLocation = location as? AGSNMEALocation else { return }

```

Reason:

The NMEA delegate method inherits from the `AGSLocationChangeHandlerDelegate`... But I'll let our team know that the API design here is a bit confusing, and maybe we can add another `AGSNMEALocation` specific stub in the delegate.

 

References:

- Sample code

- AGSNMEALocation

AGSNMEALocationDataSourceDelegate

0 Kudos
WyattHarrell
New Contributor

Thank you so much, I appreciate the help.