Swift Playground提供了以下代码。代码的返回会导致放在触摸上的图像被分开。当没有指定返回值并且返回关键字没有跟随任何东西时,函数如何工作?有没有默认的返回值,并输入什么时候没有指定?另外,当我在Swift中使用这个代码(mac上的实际编程语言)时,Touch类型不存在。我是否需要为Swift Playground的代码导入特定的库以在Swift中工作?当未指定返回类型时,“返回”关键字如何返回非指定值? [Swift Playground]
func addImage(touch: Touch) {
if touch.previousPlaceDistance < 50 {
return
}
let graphic = Graphic(image: ⭐️)
scene.place(graphic, at: touch.position)
}
触摸不存在,因为您不会在Mac上触摸屏幕,只能在iPhone或iPad上触摸屏幕 –
当创建实际应用程序时无法使用Touch类时,学习如何使用Touch类? –
那么,你可以使用它的iOS,而不是OSx –