How to properly release retained arguments of an NSInvocation?
Are the retained arguments released when the NSInvocation is deallocated, or do I need to do a release manually on the objects in the argument list of an NSInvocation?
The "retained arguments"? The arguments are not automatically retained by NSInvocation. See:
This class does not retain the arguments for the contained invocation by default. If those objects might disappear between the time you create your instance of NSInvocation and the time you use it, you should explicitly retain the objects yourself or invoke the retainArguments method to have the invocation object retain them itself.
When you use "retainArguments" you don't have to manually release them again. NSInvocation does that for you by adding them to the autorelease pool. See: http://www.cocoabuilder.com/archive/cocoa/241994-surprise-nsinvocation-retainarguments-also-autoreleases-them.html
Via Google, I found this conversation, which explains the key reason why you don't need to release the arguments:
So I decided to -retainArguments, and presumed that this meant I was supposed to release the target and arguments when I was done with them.
As you've discovered, no, you're not supposed to do that. You have not retained the target and arguments. You have told the NSInvocation to do so, and it then has responsibility for releasing them.
(I'd also recommend you read the Memory Management Programming Guide for some other such patterns and insights.)