xcode swift可可应用程序无法将消息打印到控制台[已关闭]

tjjdgumg  于 2023-05-23  发布在  Swift
关注(0)|答案(1)|浏览(117)

**关闭。**此题需要debugging details。目前不接受答复。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答这个问题。
9小时前关闭。
Improve this question
我是可可的新手,我写了一个简单的可可应用程序

import Cocoa

class ViewController: NSViewController {
    var button:NSButton!

    override func viewDidLoad() {
        super.viewDidLoad()
        print("viewDidLoad")
        NSLog("com.gg.myvpn : %@", "gggg")

        // Do any additional setup after loading the view.
        button = NSButton(frame: CGRect(x: 10, y: 100, width: 50, height: 50))
        button.title = "aaa"
        button.target = self
        button.action = #selector(self.pressed)
        self.view.addSubview(button)
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }

    @objc func pressed(){
        if button.title == "aaa"{
            button.title = "bbb"
            VPNHandler.connectVPN()
        } else{
            button.title = "aaa"
        }
        NSLog("%@", "pressed")
    }
}

在生成和运行之后,控制台没有打印任何消息。
print()和NSLog()不起作用

elcex8rz

elcex8rz1#

你是对的,print()NSLog()都写入控制台,但它们在默认情况下可能不可见(在Xcode中)。检查;

  • 输出:View> Debug Area> Activate Console
  • 调试:Product> Scheme> Edit Scheme,然后Run> Arguments,并确保Arguments Passed On Launch为空(或包含所需的pass)。则Options> Console> Use Terminal

相关问题