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
}
}
Solved! Go to Solution.
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:
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:
Thank you so much, I appreciate the help.