作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
<分区>
我正在用 Swift 4.0 更新我的源代码我面临以下与属性文本相关的问题
以下代码在 swift 3.2 中运行良好。
entemessageText.highlightTapAction = { (containerView: UIView, text: NSAttributedString, range: NSRange, rect: CGRect) -> () in
let attributes = text.attributes(at: range.location, effectiveRange: nil)
if let attrs = attributes["YYTextHighlight"] as? YYTextHighlight {
if let url = attrs.userInfo!["url"] as? String {
self.openUrl(URL(string: url)!)
}
}
}
“无法使用类型为‘String’的索引下标类型为‘[NSAttributedStringKey:Any]’的值”
我用相同的关键字搜索解决方案,但没有得到任何结果。
任何帮助或建议都会有所帮助。
我是一名优秀的程序员,十分优秀!