PreferencesTableViewController
class PreferencesTableViewController : UITableViewController, UINavigationBarDelegate, UIDocumentPickerDelegate
There are two preferences available:
- use or not cache
- select the map source (tile server)
Preferences are kept on UserDefaults with the keys kDefaultKeyTileServerInt (Int)
and kDefaultUseCache` (Bool)
-
Delegate for this table view controller.
Declaration
Swift
weak var delegate: PreferencesTableViewControllerDelegate? -
Global Preferences
Declaration
Swift
var preferences: Preferences -
Declaration
Swift
var cache: MapCache -
Store cached size for reuse.
Declaration
Swift
var cachedSize: String -
Does the following:
- Defines the areas for navBar and the Table view
- Sets the title
- Loads the Preferences from defaults
Declaration
Swift
override func viewDidLoad() -
Close this controller.
Declaration
Swift
@objc func closePreferencesTableViewController() -
Loads data
Declaration
Swift
override func viewDidAppear(_ animated: Bool) -
Does nothing for now.
Declaration
Swift
override func didReceiveMemoryWarning()
-
Returns 4 sections: Units, Cache, Map Source, Activity Type
Declaration
Swift
override func numberOfSections(in tableView: UITableView?) -> Int -
Returns the title of the existing sections. Uses
kCacheSection,kUnitsSection,kMapSourceSectionandkActivityTypeSectionfor deciding which is the section titleDeclaration
Swift
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? -
For section
kCacheSectionreturns 2, forkUnitsSectionreturns 1, forkMapSourceSectionreturns the number of tile servers defined inGPXTileServer, and for kActivityTypeSection returnsCLActivityType.countDeclaration
Swift
override func tableView(_ tableView: UITableView?, numberOfRowsInSection section: Int) -> Int -
For
kCacheSection:- If
indexPath.rowis equal tokUserOfflineCacheCell, returns a cell with a checkmark - If
indexPath.rowis equal tokClearCacheCell, returns a cell with a red textkClearCacheCell
If the section is kMapSourceSection, it returns a chekmark cell with the name of the tile server in the
indexPath.rowindex inGPXTileServer. The cell is marked ifselectedTileServerIntis the same asindexPath.row.If the section is kActivityTypeSection it returns a checkmark cell with the name and description of the CLActivityType whose indexPath.row matches with the activity type.
Declaration
Swift
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell - If
-
Performs the following actions depending on the section and row selected: If the cell
kUseImperialUnitCellinkUnitsSectionit sets or unsets the use of imperial units (useImperialinPreferencesand calls the delegate methoddidUpdateUseImperial`.If a cell in kCacheSection is selected and the cell is 1. kUseOfflineCacheCell: Activates or desactivates the
useCacheinPreferences, and calls the delegate methoddidUpdateUseCache2. KClearCacheCacheCell: Clears the current cache and callsIf a cell in
kMapSourceSectionis selected: UpdatestileServerIntinPreferencesand calls the delegate methoddidUpdateTileServerIf a cell in
kActivitySectionis selected: Updates theactivityTypeinPreferencesand calls the delegate methoddidUpdateActivityType.In each case checks or unchecks the corresponding cell in the UI.
Declaration
Swift
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
-
Declaration
Swift
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL])
View on GitHub
PreferencesTableViewController Class Reference