This question has been asked an awful amount of times on Stack Overflow, but still without a conclusive answer. This is why I'm asking again. Hopefully in a clear way.
How do I call the social function from the viewController from an SKScene?
This is the touchesBegan
function in my SKScene:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) == self.twitterButton {
println("Twitter button")
}
if self.nodeAtPoint(location) == self.facebookButton {
println("Facebook button")
}
}
}
This is the function inside of my GameViewController:
func postToFacebook() {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
var controller = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
controller.setInitialText("Testing Posting to Facebook")
self.presentViewController(controller, animated:true, completion:nil)
} else {
println("no Facebook account found on device")
}
}