iphone - How to keep the ASIHTTPRequestDelegate even when if the user poped from that view controller? -


i have application in need have settings page,which has credentials of user can edit that.its table view loading array taken httprequest.by clicking on each of have option go aother view , update value , come back.i have done update call server on update view this..

 dispatch_async(backgroundqueue_, ^{             [self performselectorinbackground:@selector(load) withobject:nil];              dispatch_sync(dispatch_get_main_queue(), ^{                  [self showhud];              }); 

because in mainqueue doing popping operation.so need update service called in background.but problem when coming calling service in settings viewcontroller.to load updated value.some times delegates of request getting crashed.i calling service this.

asiformdatarequest *request = [asiformdatarequest requestwithurl:url];    [request setpostvalue:uidstr forkey:@"userid"];      request.userinfo=[nsdictionary dictionarywithobject:@"update" forkey:@"type"];     [request setpostvalue:self.string forkey:@"age"];     [request setdelegate:self];     [request setcachepolicy:asiaskserverifmodifiedcachepolicy|asifallbacktocacheifloadfailscachepolicy];     [self showhud1];         [request startasynchronous]; 

can point me how can out crashing app.i think problem delegate getting nil.

decouple network requests view controller code. way if views unloaded, network delegate still exist.

for example: make networkrequest singleton class communication network, , use mechanism nsnotifications, or @protocol interface in singleton class view controllers become delegates of, pass results , status changes needed.

for tutorial on singletons in objective-c, see: http://www.galloway.me.uk/tutorials/singleton-classes/


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -