我的所有打印语句都没有出现在Xcode控制台中

问题描述 投票:1回答:1

我创建了这个名为createTeams()的函数,它正在为表创建数据。

func createTeams() {
    let team1 = teams(Team1: "Chelsea", Team2: "Arsenal" , startTime: "15/06/2019", location: "London")
    let team2 = teams(Team1: "Barcelona", Team2: "Manchester" , startTime: "16/06/2019", location: "London")
    let team3 = teams(Team1: "Real Madrid", Team2: "FC Bayern" , startTime: "17/06/2019", location: "London")
    let team4 = teams(Team1: "Chelsea", Team2: "Juvantis" , startTime: "18/06/2019", location: "London")
    let team5 = teams(Team1: "LiverPool", Team2: "FC Dallas" , startTime: "19/06/2019", location: "London")
    let team6 = teams(Team1: "Atlanta FC", Team2: "NewCastle Utd." , startTime: "20/06/2019", location: "London")

    teamsList.append(team1)
    teamsList.append(team2)
    teamsList.append(team3)
    teamsList.append(team4)
    teamsList.append(team5)
    teamsList.append(team6)
}

我在viewDidLoad中调用此函数,它工作正常。

但是,我在print中有这个viewDidLoad声明不起作用。

override func viewDidLoad() {
    super.viewDidLoad()
    print("Awake");

    self.createTeams()
    tableView.dataSource = self
    tableView.delegate = self
}

我甚至有一个简单的打印语句按钮也无法正常工作。

@IBAction func subscribeButtonClicked(_ sender: UIButton) {
    print("Subscribe Button Clicked")

    if(isSubscribed) {
        print("User Subscribed to this ");
        isSubscribed = false
    } else {
        print("User Unsubbed");
        isSubscribed = true
    }
}

编辑:这是我正在开发的watchKit项目所以它从手表界面加载并从那里打印,以便打印那些我必须在iPhone模拟器上单独运行项目的语句

ios swift xcode watchkit
1个回答
1
投票

问题是有时xcode调试器由于某些内部不一致或其他原因而崩溃。所以我们编写的print语句无法在调试器窗口中显示。

您需要执行以下步骤:

  1. 清理xcode。
  2. 强制退出xcode。
  3. 清理派生数据。
  4. 重启xcode并运行它。

它会工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.