I\'m working on a tab bar application and one of the tabs has a UISearchDisplayController hooked up to a UISearchBar. It\'s all connected up in the NIB and is working. When I ta
Usually child objects shouldn't retain its parent. In this case its the parent controller that should retain the child (which is the search display controller).
This has been done for you automatically when you're creating the SDC in NIB file because it has been added to the view controller's searchDisplayController
property and thus retained for the view controller's lifetime.
However since setting the searchDisplayController
property on a view controller is considered usage of private api. You should just add an ivar to retain it and release it on dealloc manually.
Simply removing the autorelease
call is a memory leak as you're leaving around an object you init
-ed without saving a reference to it so I don't think it is the correct answer.
Instead you should retain the searchController
properly in an ivar and release it on properly on dealloc as you would any object you want to stay alive for the lifetime of the view controller.