I have a custom UITextView
that takes advantage of Apple\'s TextKit by defining a custom NSTextStorage
class, however, when I use my subclass for t
Wow.... weird, it got fixed when I changed the type of storage
to NSTextStorage
....
typealias PropertyList = [String : AnyObject]
class BMTextStorage : NSTextStorage {
overrride var string: String {
return storage.string
}
private var storage = NSTextStorage()
override func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> PropertyList {
return storage.attributesAtIndex(location, effectiveRange: range)
}
override func replaceCharactersInRange(range: NSRange, withString str: String) {
storage.replaceCharactersInRange(range, withString: str)
edited([.EditedAttributes, .EditedCharacters], range: range, changeInLength: str.length - range.length)
}
override func setAttributes(attrs: PropertyList?, range: NSRange) {
storage.setAttributes(attrs, range: range)
edited([.EditedAttributes], range: range, changeInLength: 0)
}
override func processEditing() {
super.processEditing()
}
}