Iphone stop an ASIFormDataRequest -


i have problem in viewcontroller when have pending asiformdatarequest (started asynchronous task) still executing , user presses button (in order pop view).

is there way stop asynchronous task?

i have read method called "cleardelegatesandcancel" don't know if i'm looking for.

thanks

thing is, call cleardelegatesandcancel, have have handle asifromdatarequest object that's running asynchronously. means should set property, like...

@interface myviewcontroller : uiviewcontroller <asihttprequestdelegate> {     asiformdatarequest *therequest     ... }  @property (nonatomic, retain) asiformdatarequest *therequest; 

then in .m, don't declare new request object, assign formdatarequest class's ivar:

@synthesize therequest;  -(void)viewdidload  //or whatever {     self.therequest = [asiformdatarequest requestwithurl:myurl];     // configure , fire request, being sure set .delegate self }  -(void)viewwilldisappear:(bool)animated //or whatever {     [self.therequest cleardelegatesandcancel]; }   -(void)dealloc {     [therequest release];  //don't not this. } 

point is, need set you've got request to talk to while it's running asynchronously.

by way, practice. if viewcontroller goes away (say getting popped off uinavcontroller stack) before request returns, it'll try call delegate method on deallocated object, , boom.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -