objective c - mutableCopy memory leak -


can shed light why use of mutablecopy leaking memory?

- (id)objectinlistatindex:(unsigned)theindex {        nssortdescriptor *descriptor = [[[nssortdescriptor alloc] initwithkey:@"notenumber"  ascending:yes] autorelease];        [list sortusingdescriptors:[nsarray arraywithobjects:descriptor,nil]];        nsmutablearray *thearray = [list mutablecopy];        nsdictionary *thedict = [thearray objectatindex:theindex];        return thedict;  } 

because mutablecopy returns retained object, , never release thearray.

copy methods return retained object caller responsible releasing. detailed in api docs , memory management guide.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -