I have the following piece of code in which I have inherited a class from NSMutableAttributedString
and when I call the append method within the method of my class, app crashes. I just want to learn the reason. Can anyone help me?
class Str: NSMutableAttributedString {
override init() {
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func getStr(s:String) {
self.append(NSMutableAttributedString.init(string: s))
print(self)
}
}
The error message is:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -string only defined for abstract class. Define -[string.str string]!'