swiftfacebookslcomposeviewcontrollersocial-framework

How do I display a variable and a words at once when posting a Highscore on Facebook (swift)?


Hi I making a basic game and I want to be able to post the users highscore on Facebook along with presets words so all the user has to do is click the post button. So basically all I need is "My highscore is xxx". i have it posting on Facebook but can't seem to put the words in with the highscore xxx.

SharetoFacebook.setInitialText("My highscore is" + finalTime.text)

where final time is a label. if i take out the "My highscore is" it will post the highscore. And if i take out the finalTime.text it will only post the words. How do I combine these together in swift?


Solution

  • SharetoFacebook.setInitialText("My highscore is /(finalTime.text!)")
    

    You can add a variable to a string by writing /() with the variable name inside.