如何在 iPad 上的 Swift Playgrounds 中打印到控制台? [英] How can I print to console in Swift Playgrounds on iPad?

查看:28
本文介绍了如何在 iPad 上的 Swift Playgrounds 中打印到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Swift Playground 的Sources"文件夹深处调试一个方法.

public func WantDebugThis() {让 x = 42let text = "带有有用信息的调试消息:x = \(x)"打印(文本)}

在 macOS Playground 中,print 输出显示在调试区域中,如

I would like to debug a method deep inside my "Sources" folder within a Swift Playground.

public func wannaDebugThis() {
    let x = 42
    let text = "Debug message with useful information: x = \(x)"
    print(text)
}

Within a macOS playground, the print output is shown in the debug area, as described in this question.

On iPad however, the print statement seems to be ignored. Even within Console.app on mac, I cannot find the desired output.

How do I write debug statements on iPad and where do I find them?

解决方案

In order to write debug messages from the iPad to the console, NSLog() has to be used.

public func wannaDebugThis() {
    let x = 42
    let text = "Debug message with useful information: x = \(x)"
    NSLog(text)
}

The output of NSLog() can be found under the process named ExecutionExtension in Console.app on macOS. The output of print messages is only shown as <private>, which can be seen on attached screenshot.

这篇关于如何在 iPad 上的 Swift Playgrounds 中打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆