I've got some serious memory leaks in the app, and I've traced them to this method.
Is the above code ok from a memory management point of view, assuming the method that receives the object releases it?
Should I be using autorelease here somewhere? Does that work?
It depends on the name of the method. Convention is that methods called (or containing) alloc, new, copy or retain return retained objects and the caller is responsible for releasing them. In other cases methods return autoreleased objects.
This is all covered in the Memory Management Programing Guide in the documentation.
I've got some serious memory leaks in the app, and I've traced them to this method.
Is the above code ok from a memory management point of view, assuming the method that receives the object releases it?
Should I be using autorelease here somewhere? Does that work?
thanks for any tips.
Yes. As long as you make sure that anything calling that function at some point calls release on the pointer it gets, then you won't get a leak.
__________________
Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----