ios - Xcode Playground 不执行功能

标签 ios xcode swift-playground

我创建了一个新的 Playground 并添加了简单的函数,但该函数从未被调用过:

var str = "New playground"

func hello()
{
    print("Hello, World")
}

enter image description here

你们知道为什么函数没有被调用吗?

非常感谢你的帮助

最佳答案

因为你没有调用函数。只需调用它:

func hello()
{
    print("Hello, World")
}

hello()

关于ios - Xcode Playground 不执行功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33378542/

相关文章:

ios - "Undefined symbols for architecture i386"问题

ios - 解析 PFQuery whereKey :notEqualTo is not working for PFUser objects

ios - 以下哪项将设置UISegmentedControl的字体?

swift - 如何在 Swift 中正确打印 block 参数?

ios - 在 playground 中导入第三方 .framework 文件

swift - 如何在 Swift 的 playground 中获取用户输入?

ios - Xcode 可以在 XIB 中查找/替换吗?

ios - yarn run ios 运行模拟器但不显示应用程序图标

iphone - Xcode 看不到我的 iOS 设备,但 iTunes 可以

ios - 使用自定义相机覆盖 View 时底部的黑色 View (UIImagePickerController)