1

In my GameViewController i have this function:

 func shareButton(){
  var myShare = "test"
    let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [myShare], applicationActivities: nil)
    self.presentViewController(activityVC, animated: true, completion:nil)
 }

I Want to call this function from my GameScene, I tried it like this but it won't work:

GameViewController.shareButton()

This gives the error: "Missing argument for parameter #1 in call"

What is the proper way to make this work?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
sdd
  • 889
  • 8
  • 29
  • Sounds like `GameViewController` is not an instance of GameViewController but rather the class. See: http://stackoverflow.com/questions/24087936/how-do-i-make-class-methods-properties-in-swift – CodeSmile Dec 20 '14 at 13:58
  • I tried to change func shareButton() into class func shareButton() but that also doesn't work.. – sdd Dec 20 '14 at 14:04

1 Answers1

0

In your game scene you can create a variable like this:

var gameViewController = GameViewController()

And then type this:

gameViewController.shareButton()
Wiem
  • 163
  • 8
  • ok I got it thank you. and is my shareButton function good? because app crashes when this function starts(lldb error) – sdd Dec 22 '14 at 13:07
  • Does it show your app delegate with a green breakpoint line above the debugger? If it does what does the right side of the green line say? – Wiem Dec 23 '14 at 22:49
  • Can you please see my other question: http://stackoverflow.com/questions/27621157/sharing-highscore-with-social-media – sdd Dec 24 '14 at 13:11