我创建一个游戏想要能够添加得分,所以当他们在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];
}
代码可以正常运行
高分
有
有没有办法可以将它添加到字符串中以便显示?
答案 0 :(得分: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];