Swift 2.0:Count不可用访问集合上的count属性

时间:2015-08-01 17:53:55

标签: ios swift uiviewcontroller uitextfield uitextfielddelegate

我将文本字段的限制设置为300

时出错
class ViewController: UIViewController, UITextFieldDelegate {

    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        let newLength = count(textField.text!.utf16) + count(string.utf16) - range.length
        return newLength <= 300 // Bool
    }

}

0 个答案:

没有答案