Skip to content

Commit

Permalink
Merge pull request #65 from vincentneo/fix/64
Browse files Browse the repository at this point in the history
Fix incorrect gpx extensions tagging when parent tag exists
  • Loading branch information
vincentneo committed Nov 14, 2019
2 parents f639471 + 34e9121 commit 97c6bd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 1 addition & 15 deletions Classes/GPXExtensions.swift
Expand Up @@ -140,21 +140,7 @@ public final class GPXExtensions: GPXElement, Codable {
}

// MARK:- Unavailable classes

/// Insert a dictionary of extension objects
///
/// - Parameters:
/// - tag: Parent Tag. If inserting without the parent tag, this value should be `nil`
/// - contents: Contents as a dictionary to be inserted to this object.
@available( *, unavailable, message: "Please append GPXExtensionsElement to this extension instead, or use append(at:). Read documentation to learn more.")
public func insert(withParentTag tag: String?, withContents contents: [String : String]) {}

/// Remove a dictionary of extension objects
///
/// - Parameters:
/// - tag: Parent Tag of contents for removal. If removing without the parent tag, this value should be `nil`
@available( *, unavailable, message: "Please append GPXExtensionsElement to this extension instead, or use get(from:). Read documentation to learn more.")
public func remove(contentsOfParentTag tag: String?) {}
// Have been removed.


// MARK:- GPX
Expand Down
9 changes: 9 additions & 0 deletions Classes/GPXExtensionsElement.swift
Expand Up @@ -66,6 +66,9 @@ open class GPXExtensionsElement: GPXElement, Codable {
else if let text = text {
self.addProperty(forValue: text, gpx: gpx, tagName: tagName(), indentationLevel: indentationLevel)
}
else {
super.addOpenTag(toGPX: gpx, indentationLevel: indentationLevel)
}
}

override func addChildTag(toGPX gpx: NSMutableString, indentationLevel: Int) {
Expand All @@ -76,5 +79,11 @@ open class GPXExtensionsElement: GPXElement, Codable {
}

}

override func addCloseTag(toGPX gpx: NSMutableString, indentationLevel: Int) {
if text == nil {
gpx.appendCloseTag(indentation: indent(forIndentationLevel: indentationLevel), tag: tagName())
}
}

}

0 comments on commit 97c6bd9

Please sign in to comment.