iphone - Message Sent to Deallocated Instance -



iphone - Message Sent to Deallocated Instance -

i'm using touchxml parse element in ios. retrieve response web service using nsinvocationoperation, parse , display results. works fine background thread displays results on main thread using [self performselectoronmainthread:@selector(displayloginresult:) withobject:res waituntildone:no]; error:

2011-07-18 11:58:06.108 billsapp[873:7107] *** -[cfstring release]: message sent deallocated instance 0x5d809b0

the code parse element is:

-(loginresult *) trylogin:(nsstring *)username withpassword:(nsstring*)password{ nsurl *url = [urlutility trylogin:username passwordhash:password]; cxmldocument *responseobj = [urlutility xmldocwithurl:url]; if(responseobj == [nsnull null]) homecoming [nsnull null]; cxmlelement *eleuser = [responseobj nodeforxpath:@"//user" error:nil]; cxmlelement *eleresult = [responseobj nodeforxpath:@"//result" error:nil]; loginresulttype resulttype; //nslog(@"result: "); //nslog(eleresult ); // nslog([[eleresult stringvalue] lowercasestring]); if ([[[eleresult stringvalue] lowercasestring ] isequaltostring: @"successful"]){ resulttype = successful; } else { resulttype = invalidusernameorpassword; } loginresult *res = [[loginresult alloc] init]; res.result = resulttype; (cxmlelement *resultelement in [responseobj children] ) { nslog([nsstring stringwithformat:@"%@ %@", [resultelement name], [resultelement stringvalue]]); } //todo: prepare enum parsing =[loginresult loginresulttypestringtoenum: [eleresult stringvalue]]; if(eleuser != nil) { cxmlelement *eleclientid = [eleuser nodeforxpath:@"clientid" error:nil]; cxmlelement *elecompanyname = [eleuser nodeforxpath:@"companyname" error:nil]; cxmlelement *elecompanycontact = [eleuser nodeforxpath:@"companycontact" error:nil]; cxmlelement *eleisagent = [eleuser nodeforxpath:@"isagent" error:nil]; cxmlelement *eleparentid = [eleuser nodeforxpath:@"parentid" error:nil]; nsinteger *clientid = [[eleclientid stringvalue] integervalue]; nsstring *companyname = [elecompanyname stringvalue]; nsstring *companycontact = [elecompanycontact stringvalue]; bool isagent = [utils stringtobool:[eleisagent stringvalue]]; nsinteger *parentid = [[eleparentid stringvalue] integervalue]; user *user = [[user alloc] initwithdata:clientid companyname:companyname companycontact:companycontact isagent:isagent parentid:parentid]; res.user = user; // release elements // [eleclientid release]; // [elecompanyname release]; // [elecompanycontact release]; // [eleisagent release]; // [eleparentid release]; //release raw values // [companyname release]; // [companycontact release]; } // [eleresult release]; // [eleuser release]; homecoming res; }

part of me wants it's bug touchxml, find unlikely. there way farther track downwards error?

edit: definitions properties on user class is:

@property (nonatomic, readwrite) nsinteger clientid; @property (nonatomic, retain) nsstring *companyname; @property (nonatomic, retain) nsstring *companycontact; @property (nonatomic, readwrite) bool isagent; @property (nonatomic, readwrite) nsinteger parentid;

and instance initialized with:

-(user*)initwithdata:(nsinteger *)clientid companyname:(nsstring *)company companycontact:(nsstring*)contact isagent:(bool)agent parentid:(nsinteger*)parentid { //[self = super init]; self.clientid= clientid; self.companyname= company; self.companycontact= contact; self.isagent = agent; self.parentid = parentid; homecoming self; }

and loginresult class is:

@interface loginresult : nsobject { loginresulttype result; user *user; nsstring * const loginresulttypearray[4]; } @property (nonatomic, readwrite) loginresulttype result; @property (nonatomic, retain) user *user;

just try: correctly retaining companyname , companycontatct in user class?

edit:

next thing check loginresulttypearray. how string assigned it? guess advice sound trivial you, hard come useful suggestion little code...

can't thought which cfstring beingness released? if not autoreleased object, perchance stack trace point @ method sending release message... helpful...

otherwise, seek , nslog of nsstrings addresses, can compare them address find in error log (and, again, seek , find out string reused after deallocation).

finally, approach find out string used after deletion using method swizzling replace nsstring's dealloc method of yours that, before calling swizzled dealloc, logging of objec. produce much log info, knowing address of string find need. find here info swizzling.

iphone objective-c ios touchxml

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -