shawnzizzo
shawnzizzo

Reputation: 373

ASIHTTPRequest Crashing on Second Call

I have a view controller that has a button that triggers a method to send a request to a web service (using JSON). The method triggered creates a ASIFormDataRequest object and sends the JSON string successfully to the web service. I know that this is successful because I have put NSLogs in the requestFinished method and they are writing out to the console (plus, the web service is processing the data properly).

After this has successfully executed I hit the button again (yes, sending the same data to the web service). The app crashes.

[53166:6203] *** -[CFURL release]: message sent to deallocated instance 0x4c5dd00
[Switching to process 53166 thread 0x6203]
[Switching to process 53166 thread 0x6203]

XCode then highlights the CFRunLoop() function within the runRequests method in the ASIHTTPRequests class.

I have tried calling [request cancel]; in the requestFinished method, but that doesn't work either.

Upvotes: 2

Views: 1159

Answers (1)

shawnzizzo
shawnzizzo

Reputation: 373

I was able to figure this out. As I'm still new to iOS dev and getting my head around the memory management, the answer is a little light. But basically, I was releasing an NSURL variable within my methods. As soon as I commented this out, it works.

As a side note, I also modified my code to leverage an NSOperationQueue as mentioned here: http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_queue

Upvotes: 1

Related Questions