ios - 命令因信号 : Segmentation fault: 11? 而失败

标签 ios xcode swift error-handling

我收到 command failed due to signal: Segmentation fault: 11? 错误,但我不太清楚这是为什么?它确实在调试器中提供了以下响应,但指向以下代码:

1.  While type-checking 'textFieldShouldEndEditing' at /Users/macbookair1/Documents/programming/MyApp/MyApp/SignUpViewController.swift:224:5
2.  While type-checking expression at [/Users/macbookair1/Documents/programming/MyApp/MyApp/SignUpViewController.swift:231:9 - line:252:11] RangeText="query.findObjectsInBackgroundWithBlock {
            (objects: [AnyObject]?, error: NSError?) in
            if error == nil {
                if (objects!.count > 0){


                    if (UIApplication.sharedApplication().delegate as! AppDelegate).signUpOn {
                    let myAlert = SCLAlertView().showError("Woah There", subTitle: "username \(textField.text!) is already taken", closeButtonTitle: "Got It")
                    myAlert.alertview.contentView.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
                    myAlert.alertview.circleBG.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
                    myAlert.alertview.labelTitle.textColor = UIColor.whiteColor()
                    myAlert.alertview.contentView.layer.borderColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0).CGColor
                    myAlert.alertview.viewText.textColor = UIColor.whiteColor()
                    myAlert.alertview.viewText.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
                    }
                } else {
                    print("Username is available.")
                }
            } else {
                print("error")
            }
          }"

另一个指向这段代码:

1.  While type-checking 'loadBooks' at /Users/macbookair1/Documents/programming/MyApp/MyApp/ThirdCollectionViewController.swift:103:5
2.  While type-checking expression at [/Users/macbookair1/Documents/programming/MyApp/MyApp/ThirdCollectionViewController.swift:108:9 - line:127:9] RangeText="query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in
            if error == nil {
                self.books.removeAll()
                let bookObjects = objects as! [PFObject]
                for (_, object) in bookObjects.enumerate() {
                    self.books.append(Book(pfBook: object))
                }
            }else if let secondMessage = error?.userInfo["error"] as? String
                where secondMessage == "The Internet connection appears to be offline." {
                    self.failedMessage(secondMessage)
                    self.activityIndicator.hidden = true
                    self.activityIndicator.stopAnimating()
            }
            dispatch_async(dispatch_get_main_queue()){

                self.collectionView!.reloadData()
                self.refreshControl.endRefreshing()
                self.activityIndicator.stopAnimating()
            }
        }"

如何摆脱这个错误?

最佳答案

这是一种在编译 swift 时 LLVM 本身可能发生的错误。 尝试使用替代表达式或使用更新版本的 swift(例如写作时的 2.0),我遇到过这种情况,某些时候表达式只会导致崩溃,而拆分分配甚至使用 objective-c 都不会导致崩溃.

关于ios - 命令因信号 : Segmentation fault: 11? 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32661880/

相关文章:

swift - 从可选中获取对象类型?

objective-c - 如何从 Swift 将 Int 值传递给 Objective C 函数?

iphone - iOS-如何计算UITableViewCell的默认textLabel的宽度?

ios - 无法使用类型为 'enumerateObjects' 的参数列表调用 '((AnyObject!, NSInteger, UnsafeMutablePointer<ObjCBool>) -> ())'

c++ - 如何使用 Xcode 和 C++ 将日志消息发送到控制台应用程序?

iphone - Xcode 在自动继续断点处停止

ios - 如果变量发生变化则执行函数

ios - 尝试使用几何阅读器和导航栏获得全宽 View - SwiftUI

objective-c - Unicode 格式化编译器警告 : Format specifies type 'unsigned short' but the argument has type 'int'

ios - 调整图像大小会导致分辨率低