I would like to create a super class in a framework that modifies IBOutlet properties. However, I would like a subclass to be connected to the storyboard, since I don't want to connect the controls to the class in the framework.
For example, the super class in my framework looks like this:
public class MySuperDetailViewController: UIViewController {
@IBOutlet public weak var titleLabel: UILabel?
@IBOutlet public weak var dateLabel: UILabel?
@IBOutlet public weak var contentWebView: UIWebView?
...
}
Then in the subclass, I would like to control-drag controls onto the subclass. So I have to expose those properties by overriding. I'm trying to do this but it won't allow me:
class MyDetailViewController: MySuperDetailViewController {
@IBOutlet weak var titleLabel: UILabel?
@IBOutlet weak var dateLabel: UILabel?
@IBOutlet weak var contentWebView: UIWebView?
}
The error I get is: Cannot override with a stored property 'titleLabel', 'dateLabel', and 'contentWebView'
.
How can I do this or better approach to this?
Don't try to recreate the variables in the subclass; the IBOutlet
variables still exist. You can still connect them inside of Interface Builder in a number of ways.
MyDetailViewController
Note: All UIViewController
subclasses inherit an IBOutlet named view
; this property already exists in Interface Builder even though you can't click + drag to connect it.
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