Skip to content

Commit

Permalink
Merge pull request #61 from vincentneo/fix/58-partial
Browse files Browse the repository at this point in the history
Fix GPXExtensionsElement for 'no parent' malfunction
  • Loading branch information
vincentneo authored Nov 10, 2019
2 parents 06df756 + ad25108 commit 1a01ac2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Classes/GPXExtensionsElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,24 @@ open class GPXExtensionsElement: GPXElement, Codable {

override func addOpenTag(toGPX gpx: NSMutableString, indentationLevel: Int) {
let attribute = NSMutableString()
for (key, value) in attributes {
attribute.appendFormat(" %@=\"%@\"", key, value)
if !attributes.isEmpty {
for (key, value) in attributes {
attribute.appendFormat(" %@=\"%@\"", key, value)
}
gpx.appendOpenTag(indentation: indent(forIndentationLevel: indentationLevel), tag: tagName(), attribute: attribute)
}
else if let text = text {
self.addProperty(forValue: text, gpx: gpx, tagName: tagName(), indentationLevel: indentationLevel)
}
gpx.appendOpenTag(indentation: indent(forIndentationLevel: indentationLevel), tag: tagName(), attribute: attribute)
}

override func addChildTag(toGPX gpx: NSMutableString, indentationLevel: Int) {
super.addChildTag(toGPX: gpx, indentationLevel: indentationLevel)
if let text = text {
self.addProperty(forValue: text, gpx: gpx, tagName: tagName(), indentationLevel: indentationLevel)
}

for child in children {
if let text = child.text {
self.addProperty(forValue: text, gpx: gpx, tagName: child.tagName(), indentationLevel: indentationLevel)
}
else {
child.gpx(gpx, indentationLevel: indentationLevel)
}
child.gpx(gpx, indentationLevel: indentationLevel)
}

}

}

0 comments on commit 1a01ac2

Please sign in to comment.