Why doesn't UIViewController retain its UISearchDisplayController
Why doesn't UIViewController retain its UISearchDisplayController
- Subject: Why doesn't UIViewController retain its UISearchDisplayController
- From: Heath Borders <email@hidden>
- Date: Thu, 06 Oct 2011 14:33:15 -0500
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 [2] is related. I cross-posted this
question on stackoverflow. [3]
[1] http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/searchDisplayController
[2] http://stackoverflow.com/q/2395272/9636
[3]
-Heath Borders
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden