GPXFilesTableViewController

class GPXFilesTableViewController : UITableViewController, UINavigationBarDelegate

TableViewController that displays the list of files that have been saved in previous sessions.

This view controller allows users to manage their GPX Files.

Currently the following actions with a file are supported

  1. Send it by email
  2. Load in the map
  3. Delete the file

It also displays a button “Done” in the navigation bar to return to the map.

  • List of strings with the filenames.

    Declaration

    Swift

    var fileList: NSMutableArray
  • Is there any GPX file in the directory?

    Declaration

    Swift

    var gpxFilesFound: Bool
  • Temporary variable to manage.

    Declaration

    Swift

    var selectedRowIndex: Int
  • Declaration

    Swift

    weak var delegate: GPXFilesTableViewControllerDelegate?
  • Setups the view controller.

    1. Sets the title
    2. Adds the “Done” button
    3. Loads existing GPX File list.

    Declaration

    Swift

    override func viewDidLoad()
  • Removes notfication observers

    Declaration

    Swift

    deinit
  • Closes this view controller.

    Declaration

    Swift

    @objc
    func closeGPXFilesTableViewController()
  • Reloads data whenver the table appears.

    Declaration

    Swift

    override func viewDidAppear(_ animated: Bool)
  • Disposes resources in case of a mermory warning.

    Declaration

    Swift

    override func didReceiveMemoryWarning()

Table view data source

  • returns the number of sections. Always returns 1.

    Declaration

    Swift

    override func numberOfSections(in tableView: UITableView?) -> Int
  • Returns the number of files in the section.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView?, numberOfRowsInSection section: Int) -> Int
  • Allow edit rows? Returns true only if there are files.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
  • Displays the delete button.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView,
                            commit editingStyle: UITableViewCell.EditingStyle,
                            forRowAt indexPath: IndexPath)
  • Displays the name of the cell.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  • Displays an action sheet with the actions for that file (Send it by email, Load in map and Delete).

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

UITableView delegate methods

  • Only highlight rows if there are files.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView,
                            shouldHighlightRowAt indexPath: IndexPath) -> Bool
  • Returns the name of the file in the rowIndex passed as parameter.

    Declaration

    Swift

    internal func fileListObjectTitle(_ rowIndex: Int) -> String

Action Sheet - Actions

  • Cancel button is tapped.

    Does nothing, it only displays a log message.

    Declaration

    Swift

    internal func actionSheetCancel(_ actionSheet: UIAlertController)
  • Deletes from the disk storage the file of fileList at rowIndex.

    Declaration

    Swift

    internal func actionDeleteFileAtIndex(_ rowIndex: Int)
  • Loads the GPX file that corresponds to rowIndex in fileList in the map.

    Declaration

    Swift

    internal func actionLoadFileAtIndex(_ rowIndex: Int)
  • Displays an alert with a activity indicator view to indicate loading of gpx file to map

    Declaration

    Swift

    func displayLoadingFileAlert(_ loading: Bool, completion: (() -> Void)? = nil)
  • Shares file at rowIndex.

    Declaration

    Swift

    internal func actionShareFileAtIndex(_ rowIndex: Int, tableView: UITableView, indexPath: IndexPath)
  • Asks the system to notify the app on some events

    Current implementation requests the system to notify the app:

    When a file is received from an external source, (i.e AirDrop)

    Declaration

    Swift

    func addNotificationObservers()
  • Removes the notification observers

    Declaration

    Swift

    func removeNotificationObservers()
  • Reload Table View data

    For reloading table when a new file is added while user is in GPXFileTableViewController

    Declaration

    Swift

    @objc
    func reloadTableData()