iphone - Memory leak using class member -


i use class member called "soapresults" when connecting webservice. use parser parse xml results (it json result inside web service).

- (void) parser:(nsxmlparser *) parser          didstartelement:(nsstring *) elementname          namespaceuri:(nsstring *) namespaceuri          qualifiedname:(nsstring *) qname          attributes:(nsdictionary *) attributedict { nsstring *attname = [[nsstring alloc]initwithformat:@"%@result",methodname]; if ([elementname isequaltostring:attname]) {             if (!soapresults) {                  soapresults = [[nsmutablestring alloc] init];        }            elementfound = yes;      }  [attname release]; }    

now soapresults retain member , released in dealloc. tried release in connection fail/pass did not succeed. tried not alloc @ empty results.... appriciated

edit: memory leaks inside parser:

-(void)parser:(nsxmlparser *) parser  foundcharacters:(nsstring *)string {         if (elementfound) {         [soapresults appendstring: string];//memory leak here     } } 

if soapresults retain property should change

soapresults = [[nsmutablestring alloc] init];   

to

self.soapresults = [nsmutablestring string];  

this releases old value , retains new one, avoiding leaks.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -