嘿,我在尝试将此旧代码转换为swift 3时遇到问题:
func textViewDidChange(textView: UITextView) {
let components = self.txtBody.text.componentsSeparatedByString(" \n")
self.navigationItem.title = ""
for item in components {
if countElements(item.trimmingCharacters(in: NSCharacterSet.whitespacesAndNewlines())) > 0 {
self.navigationItem.title = item
break
}
}
}
问题是countElements不正确,因为它在Swift中无法识别。我不确定如何将其转换为swift 3
任何帮助或指导都会非常感谢
Harraj