ios - Crashlytics 中的 EXC_BREAKPOINT 0x00000000e7ffdefe

标签 ios swift crashlytics twitter-fabric

我在 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!,它可能为零。尝试下面的代码:

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 - Crashlytics 中的 EXC_BREAKPOINT 0x00000000e7ffdefe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39126697/

相关文章:

ios - Flutter-带有搜索栏的自定义条形应用栏

multithreading - Cocos,如何从后台线程渲染到CCRenderTexture

ios - **** 的重新声明无效

ios - UItableView 中的 UICollectionView 只获取空的 tableview,我错过了什么?

swift - 如何检查字典值是否恰好是 Bool?

android - Crashlytics : Android Studio Gradle Error related to XML

ios - 应用商店拒绝: ASIdentifierManager

ios - 如何快速隐藏静态 UItableview 中的特定单元格?

ios - 警告 : CLSLog has been used before (or concurrently with) Crashlytics initialization and cannot be recorded

ios - Crashlytics:相同的 bundleId 但不同的项目没有崩溃