Question

I'm planning to use TBXML for my Weather app. I've used NSXMLParser with a NSURLConnection up to now, but i feel this must be able much simpler, faster and more stable (the current code is so complex minor issues keep slipping in that are hell to debug).

I've been searching for asynchronous parsers for a bit and ended up in an article ('How to choose the best xml parser for your iPhone project' on raywenderlich) which lead me to TBXML. Reading through the documentation, i saw that you can also init it with an URL, which would take away the need for using the NSURLConnection. My first question is this: What are the advantages of using NSURLRequest over this? I am going to check if the network connection is alright first before i start TBXML, so that won't be a problem.

My second question is about the asynchronousity: If i simply call initWithURL or initWithData, will its processing be asynchronous? From what i've seen, it has no delegate calls but instead you just directly get the elements from the TBXML object. If i try getting elements from it before it's done, will it simply hang there? Since this can last especially long if you use initWithURL (which would pretty much answer my first question) If so, is TBXML safe to run on another thread (which i assume it is)?

Was it helpful?

Solution

If you want to parse it asynchronously you really need a secondary thread, sockets and things like that can work on the runloop because they only have to check every once in a while whether there is data available to read. A parser really needs to use some processing powah..

Just use grand central dispatch, parse your data and use it. I can't tell you whether its threading safe but if it does not say its unsafe then its most likely safe anyways..

OTHER TIPS

http://www.tbxml.co.uk/TBXML/TBXML_Free.html

follow the link and get your answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top