gpt4 book ai didi

ios - EXC_BREAKPOINT 0x00000000e7ffdefe 在 Crashlytics

转载 作者:可可西里 更新时间:2023-11-01 01:32:15 35 4
gpt4 key购买 nike

我在 Crashlytics 中遇到以下错误

LoginViewController.swift line 277 LoginViewController.textField(UITextField, shouldChangeCharactersInRange : _NSRange, replacementString : String) -> Bool

我的项目中有代码:

   // MARK: - UITextFieldDelegate
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if textField == txtSearch && string != "\n"{
var substring: String = textField.text!
substring = (substring as NSString).stringByReplacingCharactersInRange(range, withString: string)
self.searchAutocompleteEntriesWithSubstring(substring)
}
return true;
}

这个错误只是偶尔发生

最佳答案

您正在强制打开您的 textField.text! ,它可能是 nil。试试下面的代码:

func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if textField == txtSearch && string != "\n"{
if let text = textField.text {
let substring = (text as NSString).stringByReplacingCharactersInRange(range, withString: string)
self.searchAutocompleteEntriesWithSubstring(substring)
}
}
return true
}

关于ios - EXC_BREAKPOINT 0x00000000e7ffdefe 在 Crashlytics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39126697/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com