KennethTsang/GrowingTextView

Subclassing

chuckurbis opened this issue · 2 comments

Hello,

First off, awesome class. I've been finding it very useful.

I had a question about subclassing. I am having a hard time figuring out how to subclass GrowingTextView. The designated initializer is to init?(coder aDecoder: NSCoder) but I'm not using the class within a xib.

I was thinking that perhaps you could make commonInit a public class and that could be overwritten. Otherwise I'm not sure if there is a way to subclass without using a coder. Any suggestions would be appreciated.

Thanks!

@chuckurbis Thanks for pointing out.

As a subclass of UITextView, there is another designated initializer:
init(frame: CGRect, textContainer: NSTextContainer?)
I am now making it public, so you may do this in your subclass:

class MyTextView: GrowingTextView {
    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        //Do something...
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        //Do something...
    }
}

Fixed in 0.1.6 90888c7

Perfect. Thank you!