XMLParser crashes when trying to parse a feed URL offline

I'm trying to have this fixed. It's clearly a bug. I've already submited a bug report (28904764) and a Radar, but never had any bugs closed and fixed. They just stay there indefinitely in the bug report portal. So, maybe some exposure will help?


I tried to isolate the issue:


This works:


if let parser = XMLParser(contentsOf: feedURL) { 
     print("Got instance \(parser)") 
}


This does not:


class Parser: XMLParser { } 

if let parser = Parser(contentsOf: feedURL) { 
     print("Got instance \(parser)") 
}


It's clean project, with nothing but those lines of code. The issue appears to happen only to subclasses of the XMLParser.


Can we ger a fix for this?

Replies

You should look at this thread. To summaries:

  • It does indeed like this this is a bug in how Swift’s

    XMLParser
    interacts with the Objective-C NSXMLParser. Thanks for filing a bug about that.
  • Most folks don’t notice this because most folks don’t subclass

    XMLPaser
    (or NSXMLParser, for that matter) but instead use it via its delegate, which is what I recommend you do.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"