I'm follow this article but when I implement on my side it's occurred errors. Basically, I want to parse GPX File on my project. Please guide me solve this problem.
protocol GpxParsing: NSObjectProtocol {
func parser(_ parser: GpxParser, didCompleteParsing locations: Queue<CLLocation>)
}
class GpxParser: NSObject, XMLParserDelegate {
private var locations: Queue<CLLocation>
weak var delegate: GpxParsing?
private var parser: XMLParser?
init(forResource file: String, ofType typeName: String) {
self.locations = Queue<CLLocation>()
super.init()
if let content = try? String(contentsOfFile: Bundle.main.path(forResource: file, ofType: typeName)!) {
let data = content.data(using: .utf8)
parser = XMLParser.init(data: data!)
parser?.delegate = self
}
}
func parse() {
self.parser?.parse()
}
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
switch elementName {
case "trkpt":
if let latString = attributeDict["lat"],
let lat = Double.init(latString),
let lonString = attributeDict["lon"],
let lon = Double.init(lonString) {
locations.enqueue(CLLocation(latitude: lat, longitude: lon))
}
default: break
}
}
func parserDidEndDocument(_ parser: XMLParser) {
delegate?.parser(self, didCompleteParsing: locations)
}
}
question from:
https://stackoverflow.com/questions/65907606/xcode-compiler-error-cannot-find-type-queue-in-scope-while-pare-gpx-file-in 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…