UIViewController's method returns the wrong type

Originator:atai.barkai
Number:rdar://21194670 Date Originated:01-Jun-2015 09:12 PM
Status:Open Resolved:
Product:Swift Product Version:Xcode Version 6.3.2 (6D2105)
Classification: Reproducible:Always
 
Summary:
UIViewController's separateSecondaryViewControllerForSplitViewController(_:)

should return type UIViewController?, but it instead returns type UIViewController.

This is important for 2 reasons:
1. By default, all VCs besides UINavigationController simply return nil.
2. It's impossible to override UINavigationController's method to return nil in a subclass.

Steps to Reproduce:
1. Create a UISplitViewController project.
2. Create a custom UIViewController subclass named ShowProblemViewController (see below).
3. Designate the split VC's primary VC to be of kind ShowProblemViewController (this can be done in Storyboard).
4. Run

class ShowProblemViewController: UIViewController{
    
    override func separateSecondaryViewControllerForSplitViewController(splitViewController: UISplitViewController) -> UIViewController {
        
        let returned: UIViewController? = super.separateSecondaryViewControllerForSplitViewController(splitViewController)
        
        if let nonNil = returned{
            println("not nil")
        }
        else{
            println("nil...")
        }
        
        return returned!
    }
}

Expected Results:
Should print "not nil".

Actual Results:
Prints "nil".

Version:
Version 6.3.2 (6D2105)

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!