我在各个网站上检查过n可以找到objective-c代码:
FBSDKShareOpenGraphObject *object = [[FBSDKShareOpenGraphObject alloc] objectWithProperties:properties];
尝试使用SWIFT实现相同功能时,我无法找到objectWithProperties
。
有人可以帮忙吗?
答案 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)