tags:

views:

129

answers:

1

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:

http://www.argos.co.uk/webapp/wcs/stores/servlet/CheckPriceAndStockCmd?langId=-1&POSTCODE=BT635TE&jspStoreDir=argos&storeId=10001&partNum=340%2F9251&ddkey=CheckPriceAndStockCmd

How can I load the resulting content from the second URL so that I can parse it?

+1  A: 

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 NSMutableData where you're storing your results is still valid, and that it hasn't been released or deallocated.

  • Make sure that the NSURL and NSURLRequest have been successfully created before instantiating and starting the NSURLConnection... if construction of the url or request fails, you may be getting nil instead of the instance you anticipated.

  • Insert some breakpoints to see how far the connection gets through the NSURLConnection delegate 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.

Jarret Hardie
The debugger was running and just before the app quits the following is output in the gdb:The Debugger has exited due to signal 2 (SIGINT).The Debugger has exited due to signal 2 (SIGINT).Therefore I unchecked the Stop on Debugger() option on the run menu and the app doesn't quit now.
redspike