swishy
03/06/2020, 9:25 PMactual fun parse(xml: String) {
xml.usePinned {
val bytes = it.get().encodeToByteArray()
val pointer = StableRef.create(bytes)
val data = NSData.dataWithBytes(pointer.asCPointer(), bytes.size.toULong())
this.parser = NSXMLParser(data = data)
this.parser.delegate = this
this.parser.parse()
}
this.parser.setDelegate(null)
println("Parsing Done")
}
Delegate get called for start doc but then parsing fails with NSXMLParserErrorDomain error 4. which would indicate the NSData was empty but it doesnt appear to be the case, is there something Im missing?swishy
03/06/2020, 9:56 PMactual fun parse(xml: String) {
val bytes = xml.encodeToByteArray()
this.usePinned { parserRef ->
bytes.usePinned { xmlRef ->
val data = NSData.dataWithBytes(xmlRef.addressOf(0), bytes.size.convert())
this.parser = NSXMLParser(data = data)
this.parser.delegate = this
this.parser.parse()
}
}
this.parser.setDelegate(null)
println("Parsing Done")
}