IBOutlet with protocol type cannot be connected to an instantiated object

Originator:marcus.schroeder
Number:rdar://23273631 Date Originated:27-Oct-2015
Status:Closed Resolved:Duplicate of 17023935 (Open)
Product:Xcode Product Version:7.1 (7B91b)
Classification: Reproducible:Always
 
Summary:
To encapsulate functionality, I want to define a data source-protocol for my view controller. When I define an IBOutlet for the protocol type, I cannot connect it to an instantiated object of some type that implements said protocol. Only after changing the type of the IBOutlet to the class type, I can connect it. This is unexpected, since e.g. UITableViews can be hooked up to any object implementing a certain protocol.

Steps to Reproduce:
1. Create a project with a view controller
2. Define some protocol in the project
3. Add an outlet to the view controller like this @IBOutlet weak var dataSource: ViewControllerDataSource!
4. Create a class that implements said protocol
5. Instantiate an object in the storyboard of the view controller and assign it said class
6. Try to hook it up to the outlet defined in step 3

Expected Results:
The outlet connection highlights when the cursor hovers over the instantiated object, I can let go of the mouse button and an outlet connection is established.

Actual Results:
There is no highlighting of the instantiated object and no connection can be made.

Version:
Version 7.1 (7B91b) / 10.11.1 (15B42)

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!