An instance of class UITextField was deallocated while key value observers were still registered with it. -



An instance of class UITextField was deallocated while key value observers were still registered with it. -

hello getting error

an instance 0x18872c0 of class uitextfield deallocated while key value observers still registered it. observation info leaked, , may become mistakenly attached other object. set breakpoint on nskvodeallocatebreak stop here in debugger.

i observing changes made on textfield in viewdidload

[textnumber addobserver:self forkeypath:@"text" options:0 context:nil];

this responds @ here

- (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { if (textnumber.text.length==0) { [buttonmakeaudiocall setimage:[uiimage imagenamed:@"off_green_btn.png"] forstate:uicontrolstatenormal]; buttonmakeaudiocall.userinteractionenabled=no; }else{ [buttonmakeaudiocall setimage:[uiimage imagenamed:@"green_btn.png"] forstate:uicontrolstatenormal]; buttonmakeaudiocall.userinteractionenabled=yes; }

}

unfortunately app crashes within next method when response comes.

nsurl *url = [nsurl urlwithstring:string]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler:^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { if (data.length > 0 && connectionerror == nil) { nsdictionary *greeting = [nsjsonserialization jsonobjectwithdata:data options:0 error:null]; nsstring *balance = [greeting objectforkey:@"balance"]; nslog(@"balance %@",balance); labelstatus.text=[nsstring stringwithformat:@"%@€",balance]; } }];

what understood textfield object/observer released @ point , need handle it.but how?i using arc.if knows improve provide more info on situation,i handle it.

i found out reason.it error side.just before entering view controller ,i'm calling method. i'm writing next code.

nsurl *url = [nsurl urlwithstring:string]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler:^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { if (data.length > 0 && connectionerror == nil) { nsdictionary *greeting = [nsjsonserialization jsonobjectwithdata:data options:0 error:null]; nsstring *sipserver = [greeting objectforkey:@"ip"]; nsstring *port = [greeting objectforkey:@"port"]; nsstring *control_url = [greeting objectforkey:@"control_url"]; nsstring *version = [greeting objectforkey:@"version"]; [[nsuserdefaults standarduserdefaults] synchronize]; [self.navigationcontroller popviewcontrolleranimated:yes]; [[nsuserdefaults standarduserdefaults]setbool:yes forkey:@"login"];

the problem line.

[self.navigationcontroller popviewcontrolleranimated:yes];

im poping parent view controller of current view controller.because i've used blocks,this happens this.anyhow found out solution.this had nil textfield or key value observer.hope reply helps 1 .thanks.

uitextfield key-value-observing ios7.1

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

html - Submenu setup with jquery and effect 'fold' -

ruby on rails - Devise Logout Error in RoR -