【发布时间】:2015-12-16 04:26:36
【问题描述】:
我收到了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()
}
}"
如何摆脱这个错误?
【问题讨论】:
标签: ios xcode swift error-handling