parser.parse() in Swift leads to EXC_BAD_ACCESS

后端 未结 2 1920
情话喂你
情话喂你 2021-01-05 00:42

I\'m following this tutorial as a jump start for an RSS feeder app I\'m working on in Swift. I know there are some things that have changed in Swift since this tutorial, but

2条回答
  •  甜味超标
    2021-01-05 01:22

    There seems to be an error in the automatically translated headers that assumes that qualified name spaces are always used, however, since they can be nil sometimes, it crashes.

    If you use:

    func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: [NSObject : AnyObject]!)
    

    by making the namespace and qualifiedName parameters implicitly unwrapped (or explicitly wrapped should work as well) you should be good to go.

    You'll probably have to make similar changes for any delegate methods you provide that take namespaceURI or qualifiedName parameters.

提交回复
热议问题