according to picture it report an object leak how can i fix this issue?
A:
Just like alloc... whenever you call a method with the word copy in it... by convention you are in charge of releasing whatever object was returned. That's all I can really make with the size of the picture.
Ryan Ferretti
2010-02-13 13:42:27
thanks for your advise, Ryan Ferretti
RAGOpoR
2010-02-13 13:52:28
+3
A:
Don't use [item copy]
, your stories
collection will retain the item
copy which will over-retain the copy. Add it to stories
directly, or if you must make a copy for immutability reasons, try [[item copy] autorelease]
.
dreamlax
2010-02-13 13:42:38
+3
A:
You are copying an object and adding it to an array without decrementing its refcount, which is a leak. You should change
[stories addObject:[item copy]];
to either
[stories addObject:item];
or
[stories addObject:[[item copy] autorelease];
Depending on whether you want a copy of the item, or the item itself.
Also, next time cut and past your code so that it is readable.
Louis Gerbarg
2010-02-13 13:44:43