gpt4 book ai didi

swift - 我如何将在 playgrounds 中编写的顶级代码转换为 iOS 应用程序

转载 作者:行者123 更新时间:2023-11-28 10:24:22 24 4
gpt4 key购买 nike

我已经尝试将代码从 playground 复制到 iOS 开发环境,它显示错误 ="Expressions are not allowed at the top level"

我已经将这段代码从 playgrounds 复制到 iOS viewController 和 AppDelegate

var ovalPath = UIBezierPath(ovalInRect: CGRectMake(59, 28, 123, 50))
UIColor.grayColor().setFill()
椭圆路径.fill()

我用这段代码画了一个椭圆。

最佳答案

我很确定您可能已将该代码放在任何函数代码空间之外。

确保您发布的代码在类似这样的函数中:

class SomeClass {
func someFunc() {
// that code goes here
}
}

关于swift - 我如何将在 playgrounds 中编写的顶级代码转换为 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29701545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com