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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -