Open GG526 opened 6 years ago
func nsRange(from range: Range<String.Index>) -> NSRange { // let from = range.lowerBound.samePosition(in: utf16) // let to = range.upperBound.samePosition(in: utf16) // utf16.distance(from: utf16.startIndex, to: from) //utf16.distance(from: from, to: to) return NSRange.init(range, in: self) // return NSRange(location:self.startIndex ,length: ) }
注释的地方是您的代码。
2、在extension中添加储存属性可以使用runtime
private func setIsTapAction(isTapAction: Bool) { objc_setAssociatedObject(self, &AssociatedKeys.tapAction, isTapAction as Bool, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) } private func getIsTapAction() -> Bool { let isTap = objc_getAssociatedObject(self, &AssociatedKeys.tapAction) as? Bool return isTap != nil ? isTap! : true }
如果用原来的实现方式会出现第二地方添加的action会清空上一次的添加的.
多谢指出
注释的地方是您的代码。
2、在extension中添加储存属性可以使用runtime
如果用原来的实现方式会出现第二地方添加的action会清空上一次的添加的.