I have a framework I've written in Swift that contains a class that extends UIView
and that has an IBOutlet
property.
The class is visible from my Objective-C app, but Interface Builder won't see the IBOutlet. Here's the code:
@objc protocol MyFrameworkDelegate {
// My delegate methods here
...
}
@objc class MyFrameworkClass: UIView {
@objc @IBOutlet var delegate:MyFrameworkDelegate?
// The rest of my class here
...
}
I set my view's class to MyFrameworkClass
in my storyboard, but the delegate
outlet isn't showing.
I tried with and without the @objc
modifier, no luck. When I inspect my class from Objective-C, the property comes up without the IBOutlet
.
Anyone else came across something like that?
EDIT
Here's the code generated by Xcode for the Swift -> Objective-C conversion:
@protocol MyFrameworkDelegate;
SWIFT_CLASS("_Nc9a0xD6MyFrameworkClass")
@interface MyFrameworkClass : UIView
@property (nonatomic) id <MyFrameworkDelegate> delegate;
...
Also, here's the error message I get when I try to run the app:
2014-06-22 21:41:59.095 MyApp Test[75211:17812266] Unknown class MyFrameworkClass in Interface Builder file.
2014-06-22 21:41:59.099 MyApp Test[75211:17812266] -[UIView setDelegate:]: unrecognized selector sent to instance 0xcf5d650
2014-06-22 21:41:59.101 MyApp Test[75211:17812266] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setDelegate:]: unrecognized selector sent to instance 0xcf5d650'
EDIT
Here's a screenshot of my storyboard:
Your module is None
, you should select it to your corresponding value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With