dispatch_async and retain (non-ARC)
<p>In a non-ARC app, I have an NSOperation subclass which is enqueued by a delegate and looks like:</p>

<pre><code>// note that the delegate and element properties are retained

-(id)initWithDelegate:(id&lt;SomeDelegate&gt;)inDelegate element:(SomeElement *)inElement
{
    if (self = [super init])
    {
        [self setDelegate:inDelegate];
        [self setElement:inElement];
    }
}

-(void)dealloc
{
    [_delegate release];
    [_element release];
    [super dealloc];
}

-(void)main
{
    // do stuff

    dispatch_async(dispatch_get_main_queue(), ^{
         [[self delegate] doSomething:[self element]];
    });
}
</code></pre>

<p>Since [[self delegate] doSomething:[self element]] will be called after my NSOperation object has likely been deallocated, do I need to make sure to retain "element" in the delegate before adding this operation to the queue? The element object is retained elsewhere in the app but it could potentially be released there. I need to make sure that when my delegate receives it back from the NSOperation, that it is still a valid object.</p>

<p>Just wondering if the act of invoking it in dispatch_async will retain the arguments passed to it. I could of course use an NSInvocation and performSelectorOnMainThread which would retain it.</p>