import UIKit
class ViewController: UIViewController {
@IBOutlet weak var text: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
let boldRange = text.rangeOfString(NSLocalizedString("bold", comment: ""))
// issue is here.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
每次使用rangeOfString
时我都会遇到此问题,但我不知道如何解决它。
答案 0 :(得分:0)
您需要访问文本视图的let boldRange = text.text.rangeOfString(NSLocalizedString("bold", comment: ""))
属性:
{{1}}