Search code examples
swiftios8interface-builderxcode6xcode6.1

Can not connect custom protocol delegate from storyboard in Xcode 6.1


I just upgraded my mac to 10.10 and Xcode to 6.1,

found a strange thing which about storyboard,

my case is using a swift project, can not connect custom protocol delegate from storyboard anymore.

the old connected which comes with old version of Xcode is fine, but I can not connect any new delegate anymore.

even I can not reconnect the old one once I removed the connected.

Does anyone occur this situation ??

============================== Updated ==============================

View Class

@objc public protocol VideoViewResizeDelegate {

    func shouldVideoViewResetLayout(videoView: GvVideoView) -> Bool;

}

@IBOutlet var resizeDelegate: VideoViewResizeDelegate?;

ViewController Class

@IBDesignable public class ViewController: UIViewController, VideoViewResizeDelegate {

...

}

Solution

  • https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html#//apple_ref/doc/uid/TP40001051

    Interface Builder

    Interface Builder does not support connecting to an outlet in a Swift file when the outlet’s type is a protocol. Declare the outlet's type as AnyObject or NSObject, connect objects to the outlet using Interface Builder, then change the outlet's type back to the protocol. (17023935)

    it's sucks...