I'm trying to sort out an issue where a feed parsing framework (FeedKit) crashes if there is no connectivity to get the contents of the specified URL (e.g. the app is offline).
So, it works when the App is online, and online only.
Whenever I try to instantiate my Parser
class with the convenience initializer of the superclass XMLParser
convenience init?(contentsOf url: URL)
The framework crashes:
In order to try and isolate the problem, and exclude some error introduced in the framework, I have recreated the issue in a clean project:
A solution that works like a charm, using a plain vanilla XMLParser of the Foundation framework:
let feedURL = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!
if let parser = XMLParser(contentsOf: feedURL) { // Works as expected
print("Got instance \(parser)")
}
And another that doesn't:
class Parser: XMLParser { }
let feedURL = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!
if let parser = Parser(contentsOf: feedURL) { // Crash!
print("Got instance \(parser)")
}
In the second example, all I'm doing is subclassing the XMLParser
class. No overrides or custom code whatsoever. And it still crashes.
Am I missing something?
Thank you
Edit:
Submitted a bug report to Apple with number 28904764 and opened up a Radar to this issue.
I'm confident that this is a bug on Apple's end, but would prefer to be wrong and have a fix.