Поскольку код Facebook неверен, я объясню, как я нашел способ сделать это, а затем опубликовать полный код.
Я забыл идею открытого графика и решил просто опубликовать простую условную строку, вызванную кнопкой. Оттуда я использовал код Facebook от here, только используя резервную копию, так как «Диалог доступа» над ним не работает полностью.
Оттуда я просто использовал [NSString stringWithFormat:%@%@%@,string1,self.score,string2];
Вот пример кода (изменен, чтобы быть универсальным для других):
-(IBAction)facebookShare:(id)sender {
//Set Variables
int scoreText
int highScoreText
//Format the description
NSString *description;
NSString *t1 = @"I just got a score of ";
NSString *t1Alt = @"I just got a new high score of ";
NSString *t2 = @"! Can you beat it?";
if (self.newHigh == NO){
description = [NSString stringWithFormat:@"%@%@%@",t1,scoreText,t2];
} else if (self.newHigh == YES){
description = [NSString stringWithFormat:@"%@%@%@",t1Alt,highScoreText,t2];
}
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Edit Me", @"name",
@"Edit Me", @"caption",
description, @"description",
@"http://Edit.Me.Too/", @"link",
@"http://And.Me.Too/", @"picture",
nil];
/* * * * * * * * * * * DO NOT EDIT BELOW THIS LINE * * * * * * * * * * * *
* *
* *
* From here on, this shows share screen *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Error publishing story: %@", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
NSLog(@"result %@", result);
}
}
}
}];
}