mbogh / NibDesignable

Elegant way of enabling IBDesignable on your nib-based views
MIT License
342 stars 74 forks source link

Infinite loop when loading my view #51

Closed nico75005 closed 7 years ago

nico75005 commented 7 years ago

I have a UITableViewCell that contains two UIView both extending NibDesignable.

In each of those view I have an initializer like the following.

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    setup()
}

This init triggers

// MARK: - NSCoding
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.setupNib()
    }

of NibDesignable. Then everytime this line gets called

``return nib.instantiate(withOwner: self, options: nil)[0] as! UIView // swiftlint:disable:this force_cast it calls my `required init?



 and I end up having an infinite loop.

I used the same type of initialisation in another view (not in a table view cell) and it works fine.

Any idea what's wrong?

Thanks
nico75005 commented 7 years ago

Nevermind... I didn't set the File's Owner class but the view's instead.