Question

I have a simple app that basically runs a method that fetches an live HTML data which then extracts some info using xpath query after a button is pressed.

Sometimes it hangs during the fetch, so what I 'm looking to do is to cancel the method then run another method (to show a button to "try again") after certain amount of time is passed.

I have tried using dispatch_async to run a method over the current one but I had no luck, as it still completes its run after dispatch_async is called. So I'm thinking cancelling the original method would stop this from happening.

What would be the best approach to solve this problem? Many thanks in advance.

Note : I am not using NSURLRequest at all atm.

Was it helpful?

Solution

I've solved this issue by implementing NSURLConnection. Because the data is downloaded asynchronously, I also implemented CFRunLoop on the connection and on connectionDidFinishLoading to run the method after it receives all data from the connection.

Hope this helps someone out there!

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