大佬教程收集整理的这篇文章主要介绍了ios – 如何在Swift中向Facebook发布故事?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是相关代码:
// Create a like action id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject]; // Link that like action to the restaurant object that we have created [action setObject:_objectID forKey:@"object"]; // Post the action to Facebook [FBrequestConnection startForPostWithGraPHPath:@"me/og.likes" graphObject:action completionHandler:^(FBrequestConnection *connection,id result,NSError *error) { __block NSString *alertText; __block NSString *alerttitle; if (!error) { // success,the restaurant has been liked NSLog(@"Posted OG action,id: %@",[result objectForKey:@"id"]); alertText = [NSString StringWithFormat:@"Posted OG action,[result objectForKey:@"id"]]; alerttitle = @"success"; [[[UIAlertView alloc] initWithtitle:alerttitle message:alertText delegate:self cancelButtontitle:@"OK!" otherButtontitles:nil] show]; } else { // An error occurred,we need to handle the error // See: https://developers.facebook.com/docs/ios/errors } }];
基本上我正在寻找这段代码的Swift翻译.在我的实际应用程序中,我将为游戏发布一个高分(不喜欢餐馆),但如果我有一些Swift可以使用,我应该能够弄清楚.
提前致谢!
// Initialize variables let name = "Purple Square" let link = "https://itunes.apple.com/us/app/purple-square/id942125866?ls=1&mt=8" let description = String(format: "I got %.1f. Can you beat me?",highscore) let picture = "https://www.dropBox.com/s/2nbaxai1arhqqrn/purpleSquareSplash.png?dl=1" let caption = "Exceptionally simple. Deceivingly hard. RiDiculously adDictive." // Add variables to Dictionary var Dict = NSMutableDictionary() Dict.SETVALue(name,forKey: "name") Dict.SETVALue(caption,forKey: "caption") Dict.SETVALue(description,forKey: "description") Dict.SETVALue(link,forKey: "link") Dict.SETVALue(picture,forKey: "picture") // Present the Feed dialog and post the story FBWebDialogs.presentFeedDialogModallyWithSession(nil,parameters: Dict,handler: nil)
以上是大佬教程为你收集整理的ios – 如何在Swift中向Facebook发布故事?全部内容,希望文章能够帮你解决ios – 如何在Swift中向Facebook发布故事?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。