Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Twitter: add high score in tweet

Hi there,
I'm developing an iPhone game. You can get a highscore.
I want to get that highscore in the twitter-text. The code for the twitter-text is:

--------
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:@"My Topscore is: **** in this game!];


[self presentModalViewController:tweetSheet animated:YES];
}

--------

The code to see the highscore in an alert-view:

--------
if (score > highscore) {
highscore = score;
NSString *nssHighscore = [NSString stringWithFormat:@"%i", highscore];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Topscore"
message:nssHighscore
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alert show];

--------
I'm using xCode 4.3.2
Please help me solve this problem! Thanks!
Post edited by jaspermeijrink on

Replies

  • DomeleDomele Posts: 2,948Registered Users
    Okay so use the same technique you used to display the highscore in the alert view to display it in a tweet. Hint: You'll be using this line:

    NSString *nssHighscore = [NSString stringWithFormat:@\"%i\", highscore];


    Another hint:

    int i = 5;
    NSString *aString = [NSString stringWithFormat:@\"The value of int i = %i\"];
    //aString, if printed, will be \"The value of int i = 5\"
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • jaspermeijrinkjaspermeijrink Posts: 6New Users
    Hi Domele,

    Thanks for your answer. The problem is: I'm a beginner and i made this game with the help of many tutorials. I don't know where i have to paste that code to get the high score (%i ??) into the tweet. What can i do?
  • sathyapriyasathyapriya Posts: 1New Users
    thanks for your idea.. If i have any further doubts will ask you definitely..
    Domele;430473 said:
    Okay so use the same technique you used to display the highscore in the alert view to display it in a tweet. Hint: You'll be sing this line:

    NSString *nssHighscore = [NSString stringWithFormat:@\"%i\", highscore];


    Another hint:

    int i = 5;
    NSString *aString = [NSString stringWithFormat:@\"The value of int i = %i\"];
    //aString, if printed, will be \"The value of int i = 5\"
  • DomeleDomele Posts: 2,948Registered Users
    Okay, you need to take a step back. I'm like 99% sure if you understood what your code was doing, you'd be able to figure this out. Copying and pasting code is not a good way to learn and you aren't going to be able to make a quality app like that.

    I'm not going to tell you explicitly what to change in your code unless you want to pay me.


    if ([TWTweetComposeViewController canSendTweet])
    {
    TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
    [tweetSheet setInitialText:@\"My Topscore is: **** in this game!];


    [self presentModalViewController:tweetSheet animated:YES];
    }


    This code basically says, if the device can tweet, create a tweet compose view controller, set the initial tweet text to "My Topscore is: **** in this game!", and then present the view controller.


    if (score > highscore) {
    highscore = score;
    NSString *nssHighscore = [NSString stringWithFormat:@\"%i\", highscore];
    UIAlertView *alert = [[UIAlertView alloc]
    initWithTitle:@\"Topscore\"
    message:nssHighscore
    delegate:nil
    cancelButtonTitle:@\"Okay\"
    otherButtonTitles:nil];
    [alert show];

    This says if score is greater than highscore, the new highscore is the current score. Then, create a string that has %i (a format specifier) in it and then replace that with the string value of 'highscore'. Finally, create an alert that has the new string we created as the message and okay as the only button.

    Hopefully from all that, you can figure out how to get your highscore into a tweet.

    And one last final clue, this:

    [tweetSheet setInitialText:@\"My Topscore is: **** in this game!];


    is the same as this:

    NSString *initialTweetText = @\"My Topscore is: **** in this game!\"
    [tweetSheet setInitialText:initialTweetText];


    And remember that I can do this:

    int i = 5;
    NSString *aString = [NSString stringWithFormat:@\"The value of int i = %i\"];
    //aString, if printed, will be \"The value of int i = 5\"
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • jaspermeijrinkjaspermeijrink Posts: 6New Users
    Is there also a way to disable the text input in my tweet? The user can now send a tweet with the highscore, but is still able to change the number of the highscore!
  • DomeleDomele Posts: 2,948Registered Users
    Nope, you cannot ban the user from changing it.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • jaspermeijrinkjaspermeijrink Posts: 6New Users
    Domele;432050 said:
    Nope, you cannot ban the user from changing it.
    Ahw, damn....
    And disable the keyboard? Now people can change the highscore. Not fair in front of the 'good-players'.
  • DomeleDomele Posts: 2,948Registered Users
    Why do you care what score people tweet? It's just to show off to their friends and everyone knows anyone can tweet "I got xxx points on xxx" on their own. Use a leaderboard to show accurate highscores.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
Sign In or Register to comment.