Swift 从另一个场景调用函数

Swift 从另一个场景调用函数,swift,sprite-kit,Swift,Sprite Kit,在我的GameViewController中,我有以下功能: func shareButton(){ var myShare = "test" let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [myShare], applicationActivities: nil) self.presentViewController(activityVC, animate

在我的GameViewController中,我有以下功能:

 func shareButton(){
  var myShare = "test"
    let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [myShare], applicationActivities: nil)
    self.presentViewController(activityVC, animated: true, completion:nil)
 }
我想从我的游戏场景中调用此函数,我尝试过这样做,但不起作用:

GameViewController.shareButton()
这会产生错误:“调用中缺少参数#1的参数”


正确的方法是什么?

在游戏场景中,您可以创建如下变量:

var gameViewController = GameViewController()
然后键入以下内容:

gameViewController.shareButton()

听起来好像
GameViewController
不是GameViewController的实例,而是类。请看:我试图将func shareButton()更改为类func shareButton(),但也不起作用..好的,我知道了,谢谢。我的shareButton功能好吗?由于此函数启动时应用程序崩溃(lldb错误),它是否会在调试器上方用绿色断点行显示应用程序委托?如果果真如此,绿线右边是怎么说的?你能看看我的另一个问题吗: