views:

70

answers:

3

according to picture it report an object leak how can i fix this issue?

alt text

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
thanks for your advise, Ryan Ferretti
RAGOpoR
+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
thanks for your advise ,dreamlax
RAGOpoR
+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
Thanks for your reply Louis Gerbarg
RAGOpoR