title: Autorelease and "assign" properties in Objective-C? (On iPhone)
body: <p>I have an instance of a UITableView, and a separate class that adheres to the delegate and datasource protocols. I'm doing this like so:</p>
  
  <pre><code>SubjectTableViewHandler *handler = [[[SubjectTableViewHandler alloc] init] retain];
  tv.delegate = handler;
  tv.dataSource = handler;
  [handler autorelease];
  </code></pre>
  
  <p>I don't want to maintain the handler as an ivar, and if I take off the <code>retain</code> call at the end, when the <code>autorelease</code> happens, it is sent <code>release</code>, then added to the pool, which causes an EXC_BAD_ACCESS. So currently, the retain count is:</p>
  
  <pre><code>(1) At init: 1
  (2) At retain: 2
  (3) delegate/datasource properties are 'assign', still 2
  (4) At autorelease: 1, now in autorelease pool.
  </code></pre>
  
  <p>But then since the properties are 'assign', they will never be released, the retain count will never hit 0, and the handler will never be deallocated anyway. Is there any more efficient way to accomplish this than maintaining the handler as an ivar and releasing it in the <code>dealloc</code> method?</p>