Can't hook custom protocol delegate from storyboard in Xcode 6.1
I just updated my mac to 10.10 and Xcode to 6.1.
found a weird thing about storyboarding,
In my case using a swift project, it is no longer possible to bind the custom protocol delegate from the storyboard.
the old connected one that ships with the old version of Xcode is fine, but I can't connect the new delegate anymore.
even i can't reconnect the old one once i removed the connected one.
Is there such a situation?
=================================================== =================================================== =========
View class
@objc public protocol VideoViewResizeDelegate {
func shouldVideoViewResetLayout(videoView: GvVideoView) -> Bool;
}
@IBOutlet var resizeDelegate: VideoViewResizeDelegate?;
ViewController class
@IBDesignable public class ViewController: UIViewController, VideoViewResizeDelegate {
...
}
source to share
Interface constructor
The Builder interface does not support plugging into an outlet in a Swift file when the output type is protocol. Declare the outlet type as AnyObject or NSObject, connect the objects to the outlet using Interface Builder, then change the outlet type back to protocol. (17023935)
it sucks ...
source to share
It's 2017 ....
Using swift 3 this will work:
open class YourClass: UIView {
#if TARGET_INTERFACE_BUILDER
@IBOutlet open weak var delegate: AnyObject?
#else
open weak var delegate: YourClassDelegate?
#endif
}
A precondition :
YourClassDelegate should be decorated with @objc
For example:
@objc public protocol MyDelegate: class {
func myFunc()
func myFunc2()
}
Update
This should be fixed in Xcode 9
source to share