In the UIViewController documentation about the searchDisplayController property 1 it says:
If you create your search display controller programmatically, this property is set automatically by the search display controller when it is initialized.
And when I create my UISearchDisplayController thusly:
[[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self] autorelease];
-[UIViewController searchDisplayController] is not nil.  However, it is nilled out after the event loop finishes, which causes the search display controller not to show when I touch inside the search bar.  Nothing crashes.  This is very weird.  If I omit the call to autorelease, everything works:
[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
However, leaks the UISearchDisplayController (I verified this with Instruments).  Since the searchDisplayController property is marked as (nonatomic, retain, readonly) I expect that it would retain the UISearchDisplayController after it is set.
This stackoverflow article is related.
 
     
     
    