Esri / data-collection-ios

Mobile data collection app using the iOS Runtime SDK.
https://developers.arcgis.com/
Apache License 2.0
25 stars 26 forks source link

Unifies API for storing and retrieving `AGSJSONSerializing` objects to/from UserDefaults #239

Closed esreli closed 4 years ago

esreli commented 4 years ago

This PR unifies the API for storing and retrieving AGSJSONSerializing objects to/from UserDefaults using generics.

Previously a user would:

UserDefaults.standard.set(newValue, forKey: visibleAreaDefaultsKey)
AGSViewpoint.retrieveFromUserDefaults(forKey: visibleAreaDefaultsKey)

This feels awkward, as if you have to use two separate APIs for the storage and retrieval. Using generics and implicit types, we can modify this API such that both storing and retrieving methods are extensions on UserDefaults, unifying the API.

UserDefaults.standard.setSerializable(newValue, forKey: visibleAreaDefaultsKey)
UserDefaults.standard.getSerializable(forKey: visibleAreaDefaultsKey)