Access @IBOutlet from a class in a framework

Hi!, I'm currently dealing with the following issue, is pretty annoying.


I have an UITableViewCell class (i will call it LabelTableViewCell):


// LabelTableViewCell.swift
open class LabelTableViewCell: UITableViewCell {
     @IBOutlet public weak var label: UILabel!
     @IBOutlet public weak var textView: UITextView!
}
    


This class i on a framework that my app is using. Everything is fine, in code i can see the framework and even use the LabelTableViewCell. The problem comes when i try to override LabelTableViewCell in my app project. The xib of the subclass don't see the @IBOutlets that are defined in LabelTableViewCell.


There is any way to fix this? there is any way to bypass it?. I need to connect these IBOutlets in my subclassed xib to change some appareance.


Thanks!

Replies

i try to override LabelTableViewCell

What do you mean by overriding ?

Do you mean subclass ?


The xib of the subclass don't see the @IBOutlets that are defined in LabelTableViewCell.

Do you create a subClass and a xib ? Or do you try to reuse the xib of the superclass ?


Could you show the full code of the subclass ?

Yes, i Mean to subclass it and i create the .swift & .xib files.


this is a short version of the super class.


open class SimpleTableViewCell : UITableViewCell {
    @IBOutlet public weak var stackView: UIStackView!
    @IBOutlet public weak var label: UILabel!
    @IBOutlet public weak var valueTextField: DropDownTextField!

    public var willUpdate: (() -> Void)?
    public var didUpdate: (() -> Void)?
    public weak var parentViewController: UIViewController?
}


The class for the subclass is something like this for now:


open class DetailedSimpleLabelPickerCell : SimpleTableViewCell {    
    public var color: UIColor?
}

Do you create a specific xib for DetailedSimpleLabelPickerCell ?


How do you register the cells ?


You wrote:

The xib of the subclass don't see the @IBOutlets that are defined in LabelTableViewCell.

subclass is DetailedSimpleLabelPickerCell ?

You do not see where ? In IB canvas ? In code ?

Could you show the code where you fail to access ?


This should work (at least compile):

class DetailedSimpleLabelPickerCell : SimpleTableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        let x = self.label
    }
}