GPXExtensions

public final class GPXExtensions : GPXElement, Codable

For adding/obtaining data stored as extensions in GPX file.

Typical GPX extended data, would have data that should be inbetween the open and close tags of <extensions>

This class represents the extended data in a GPX file.

  • Extended children tags

    Declaration

    Swift

    public var children: [GPXExtensionsElement]
  • Default Initializer.

    Declaration

    Swift

    public required init()
  • Appending children tags to extension tag, easily.

    Declaration

    Swift

    public func append(at parent: String?, contents: [String : String])

    Parameters

    parent

    parent tag’s name. If you do not wish to have a parent tag, leave it as nil.

    contents

    data to be represented as extended tag and values.

  • Get a dictionary of data from a parent tag name, easily.

    Declaration

    Swift

    public func get(from parent: String?) -> [String : String]?

    Parameters

    parent

    parent tag name, to retrieve from. Leave it as nil if parent tag should not be expected.

  • Access child element in extensions.

    If extended data does not have a parent tag, i.e:

       <extensions>
           <tag>50</tag>
       </extensions>
    

    Access it directly by extensions["tag"], and access the text attribute of it.

    If extended data does not have a parent tag, i.e:

       <ParentTag>
           <Tag>80</Tag>
       </ParentTag>
    

    Access it directly by extensions["ParentTag"]["tag"], and access the text attribute of it.

    Declaration

    Swift

    public subscript(name: String) -> GPXExtensionsElement { get }

    Parameters

    name

    name of child tag.