Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've run into the same thing. I create all of my controllers/views programmatically. Everything was working fine until I converted my project to use ARC. Once I did the <code>UISearchDisplayControllers</code> were no longer retained and the <code>searchDisplayController</code> property in each <code>UIViewController</code> was nil after the run loop ended.</p> <p>I don't have an answer why this is happening. The Apple docs suggest that the SDC should be retained by the view controller but this is clearly not happening.</p> <p>My solution was to create a second property to retain the SDC and I nil it when I unload the view. If you are not using ARC you need to release <code>mySearchDisplayController</code> in <code>viewDidUnload</code> and <code>dealloc</code>. Otherwise this is good as is.</p> <p>In MyViewController.h:</p> <pre><code>@property (nonatomic, strong) UISearchDisplayController * mySearchDisplayController; </code></pre> <p>In MyViewController.m:</p> <pre><code>@synthesize mySearchDisplayController = _mySearchDisplayController; - (void)viewDidLoad { [super viewDidLoad]; // create searchBar _mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; _mySearchDisplayController.delegate = self; _mySearchDisplayController.searchResultsDataSource = self; _mySearchDisplayController.searchResultsDelegate = self; // other stuff } - (void)viewDidUnload { [super viewDidUnload]; _mySearchDisplayController = nil; // other stuff } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload