如何使用SWIFT代码实现FBSDKShareOpenGraphObject

时间:2015-04-21 09:20:26

标签: ios swift facebook-graph-api facebook-sdk-4.0

我在各个网站上检查过n可以找到objective-c代码:

FBSDKShareOpenGraphObject *object = [[FBSDKShareOpenGraphObject alloc] objectWithProperties:properties];

尝试使用SWIFT实现相同功能时,我无法找到objectWithProperties

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

Swift使用[NSObject : AnyObject]!代替NSDictionary。并且objectWithProperties在FBSDKShareOpenGraphObject的初始化中变为properties。所以我相信你的Objective-C例子应该是:

let graphProperties : [NSObject : AnyObject]! = ["og:type": "video.other","og:title":"Test title", "og:description":"This is a test video"]
let graphObject : FBSDKShareOpenGraphObject = FBSDKShareOpenGraphObject(properties: graphProperties)