0

我正在创建一个游戏,希望能够在那里添加分数,所以当他们在 fb 上发布它时,它会向他们显示高分,(添加更多的社交方面)

这是我要起诉的代码,但它似乎无法正常工作并使应用程序崩溃,

- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
    [self postwall];

}
- (void)postwall
{
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   //kAppId, @"app_id",
                                   @"https://developers.facebook.com/docs/reference/dialogs/", @"link",
                                   @"http://fbrell.com/f8.jpg", @"picture",
                                   @"Watch Ma Balls", @"name",
                                   @"How long can you keep out of the way of ma balls for", @"caption",
                                   @"I reached a score of i% can you beat me!.",highscore, @"description",
                                   nil];

    [facebook dialog:@"feed" andParams:params andDelegate:self];
}

代码可以正常工作

高分

那里

有没有办法可以将它添加到字符串中以便显示?

4

1 回答 1

2

试试这个(假设highscore是一个int):

NSString *string = @"I reached a score of ";
string = [string stringByAppendingString:[NSString stringWithFormat:@"%d", highscore]];
string = [string stringByAppendingString:@" can you beat me?"];

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   //kAppId, @"app_id",
                                   @"https://developers.facebook.com/docs/reference/dialogs/", @"link",
                                   @"http://fbrell.com/f8.jpg", @"picture",
                                   @"Watch Ma Balls", @"name",
                                   @"How long can you keep out of the way of ma balls for", @"caption",
                                   string, @"description",
                                   nil];
于 2012-06-26T19:40:03.247 回答