Skip to content

Commit

Permalink
fix for #58 comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentneo committed Nov 1, 2019
1 parent 06df756 commit ad25108
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Classes/GPXExtensionsElement.swift
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 ad25108

Please sign in to comment.