【发布时间】:2015-12-22 11:10:05
【问题描述】:
这是我在更新到 Swift 2.0 后遇到的一个有趣的问题
错误出现在if let url = URL.absoluteString 行
func myFormatCompanyMessageText(attributedString: NSMutableAttributedString) -> NSMutableAttributedString
{
// Define text font
attributedString.addAttribute(NSFontAttributeName, value: UIFont(name: "Montserrat-Light", size: 17)!, range: NSMakeRange(0, attributedString.length))
return attributedString
}
func textView(textView: UITextView, shouldInteractWithURL URL: NSURL, inRange characterRange: NSRange) -> Bool {
if let url = URL.absoluteString {
if #available(iOS 8.0, *) {
VPMainViewController.showCompanyMessageWebView(url)
}
}
return false
}
【问题讨论】:
-
您是否查找过
absoluteString方法的文档?它是否返回一个可选的?? -
刚刚查了一下。不,它不返回可选值,但
relativeString是