2016-10-30 67 views
3

我已经看到了一些围绕着计算器但其中没有解决我的问题。我试过删除派生数据,重新输入函数,并做一个干净的。唯一可行的是注释代码,但我需要为我的应用程序的代码。没有发生错误,直到我更新到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) 
    } 
+0

哪一行是问题? – matt

+0

该错误说明了我放入第一个块的整个文本范围。 “[/Volumes/.../Developer/RLA/RLA-Volunteer/RLA Volunteer/TeamsTVC.swift:91:89 - line:109:9]的表达方式” –

+0

正确,但我们的想法是更多地评论直到找到问题的实际来源。 “二进制搜索”,你不知道。 – matt

回答

1

对于teamItem.toDictionary,尝试把teamItem.toDictionary as Any

+0

为什么这样工作? –

+0

这是一个错误,我们解决了它。 :) – matt

相关问题