Change your line in delegate method in ViewController
[tweetSheet setInitialText:@"You got xx score"];
to as shown below; to include the score with a NSString's stringWithFormat: method
-(void)showShareScreenWithScore:(NSInteger) score {
NSLog(@"showShareScreen");
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.modalPresentationStyle = UIModalPresentationFormSheet;
tweetSheet.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[tweetSheet setInitialText:[NSString stringWithFormat:@"You got %d score",score]];
NSLog(@"self = %@",self);
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else {
NSLog(@"not sls type twitter");
}
}
And from GameOverScene call this delegate method. Note: When you are creating Game over scene at that time after object instantiation you can set the property of GameOverScene. So just declare a property
@property (assign , nonatomic) NSInteger score;
and set its value Using NSURLSession that the game is getting over. And score value you can get from MainScene score property.
NSURLSession
The NSURLSession class and related classes provide an API for downloading content via HTTP. This API provides a rich set of delegate methods for supporting authentication and gives your app the ability to perform background downloads when your app is not running or, in iOS, while your app is suspended.