我已經看到了一些圍繞着計算器但其中沒有解決我的問題。我試過刪除派生數據,重新輸入函數,並做一個乾淨的。唯一可行的是註釋代碼,但我需要爲我的應用程序的代碼。沒有發生錯誤,直到我更新到Xcode中8,我的代碼,斯威夫特3命令由於信號失敗:分段錯誤:11升級到Xcode 8和Swift 3後
1. While emitting IR SIL function @_TFFC13RLA_Volunteer8TeamsTVC18addBarButtonTappedFT6senderCSo15UIBarButtonItem_T_U0_FCSo13UIAlertActionT_ for expression at [/Volumes/.../Developer/RLA/RLA-Volunteer/RLA Volunteer/TeamsTVC.swift:91:89 - line:109:9] RangeText="{ (action) in
if let team = alertController.textFields?[0].text {
if team.characters.count == 0 {
let errorAlertController = UIAlertController(title: "Add a team", message: nil, preferredStyle: .alert)
self.present(errorAlertController, animated: true, completion: nil)
return
}
let teamItem = Team(teamName: team)
let teamsRef = self.ref.child("teams")
teamsRef.child(team.lowercased()).setValue(teamItem.toDictionary, withCompletionBlock: { (error, success) -> Void in
if error != nil {
print("Error: \(error!.localizedDescription)")
}
else {
print("Data saved!")
}
})
}
}"
全功能如下:
@IBAction func addBarButtonTapped(sender: UIBarButtonItem) {
// add teams to list
let alertController = UIAlertController(title: "Add Team", message: nil, preferredStyle: .alert)
alertController.addTextField { (textField) in
textField.placeholder = "Team"
}
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alertController.addAction(UIAlertAction(title: "Add", style: .default, handler: { (action) in
if let team = alertController.textFields?[0].text {
if team.characters.count == 0 {
let errorAlertController = UIAlertController(title: "Add a team", message: nil, preferredStyle: .alert)
self.present(errorAlertController, animated: true, completion: nil)
return
}
let teamItem = Team(teamName: team)
let teamsRef = self.ref.child("teams")
teamsRef.child(team.lowercased()).setValue(teamItem.toDictionary, withCompletionBlock: { (error, success) -> Void in
if error != nil {
print("Error: \(error!.localizedDescription)")
}
else {
print("Data saved!")
}
})
}
}))
present(alertController, animated: true, completion: nil)
}
哪一行是問題? – matt
該錯誤說明了我放入第一個塊的整個文本範圍。 「[/Volumes/.../Developer/RLA/RLA-Volunteer/RLA Volunteer/TeamsTVC.swift:91:89 - line:109:9]的表達方式」 –
正確,但我們的想法是更多地評論直到找到問題的實際來源。 「二進制搜索」,你不知道。 – matt