开发者

ASIHTTPRequest Crashing on Second Call

开发者 https://www.devze.com 2023-02-27 02:26 出处:网络
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 suc

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开发者_JAVA百科] *** -[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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消