Why Take on Sane Tasks?
I’m playing with a project that requires parsing very small chunks of XML, which is something that working with an event driven library like
NSXMLParser doesn’t feel like a great fit.
So far, my version includes a public class that uses a semaphore to lock itself until the XML parsing completes, a private class that implements the
NSXMLParserDelegate methods requires, mostly to contain the fact the
NSXMLParserDelegate can’t be a pure Swift class, and an indirect enum to store the data.
The fiddly part of the concept is going to be managing the tree depth, as the XML parser has elements for starting and ending elements, which means I need to push and pop from a stack to maintain index position. I’m trying to think up a clever immutable workaround, but I think this may be a case for mutable state.
I’ll probably be adding an asynchronous parsing call that returns a completion block, but the idea is to keep the system as dead simple as possible and to shift the complexity to processing the enum tree rather than anything to do with setting up parsing itself.