Subclasses of the XMLParser class crash with the contentsOfURL initializer if there isn't connectivity, Internet or otherwise, to get the contents of the specified URL.

Originator:nmdias.pt
Number:rdar://28904764 Date Originated:22-Oct-2016 06:30 PM
Status:Open Resolved:No
Product:iOS SDK Product Version:
Classification:Crash Reproducible:Always
 
Steps to Reproduce:

1. Create an Xcode project with Xcode Version 8.0 (8A218a) and Swift 3

2. Subclass the XMLParser class like this:

class Parser: XMLParser { }

3. Try to init the subclass with the `convenience init?(contentsOf url: URL)` like this:

let feedURL = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!

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

3. Make sure there isn't internet connectivity in the simulator or the device, whichever's the case.

4. Build and Run.

5. The App will crash when attempting to init with contentsOfUrl, however, it only happens when using the subclass!


Expected Results:
I would expect the initializer to return nil, as described by the documentation: "An initialized NSXMLParser object or nil if an error occurs."

Actual Results:
The App crashes with: "Thread 1: EXC_BAD_INSTRUCTION ..."

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!