I followed the A Cocoa application driven by HTTP data blog post and have been able to successfully use the following URL to grab the HTML to use in my sample app:
http://www.argos.co.uk/static/Home.htm
However, when I use the following URL in my sample app I am not able to grab the HTML content and app just quits:
How can I load the resulting content from the second URL so that I can parse it?
There’s nothing in the code at that blog, nor the URL itself, that suggests the second URL would be an issue. If your app is just quitting, that usually suggests bad memory access of some variety. Some things to check:
Are you re-using the same connection class for the second request? If so, make sure that the
NSMutableDatawhere you’re storing your results is still valid, and that it hasn’t been released or deallocated.Make sure that the
NSURLandNSURLRequesthave been successfully created before instantiating and starting theNSURLConnection… if construction of the url or request fails, you may be gettingnilinstead of the instance you anticipated.Insert some breakpoints to see how far the connection gets through the
NSURLConnectiondelegate callback methods before it bombs.If you’re running the XCode debug profile, you should get a stacktrace in the debugger when the app quits… if that doesn’t help, try augmenting your question with information from that trace and perhaps that will inspire a bright idea for folks.