UISearchController attempts to load its view while it is deallocating

Originator:sascha
Number:rdar://22250107 Date Originated:12-Aug-2015 05:54 PM
Status:Open Resolved:
Product:iOS SDK Product Version:9.0 beta 5 (13A4325c)
Classification:Other Bug Reproducible:Always
 
Summary:
When deallocating an UIViewController that holds a strong reference to an UISearchController the following message is logged to the console: "Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x7fddc2832e10>)". This happens because UISearchController removes some gesture recognizers from its view in -dealloc, which causes the view to be loaded. A sample project is attached: just run it in the simulator, tap the button to push a table view controller with an associated UISearchController and tap "Back" to deallocate the table view controller.

Steps to Reproduce:
1. Deallocate an UIViewController that holds a strong reference to an UISearchController.

Expected Results:
The UISearchController does not attempt to load its view while it is being deallocated.

Actual Results:
The UISearchController attempts to load its view while it is being deallocated.

Regression:
Reproducible at least on iOS 9 beta 5. Did not happen with iOS 8.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!