我已经在各个站点进行过检查,可以找到Objective-C代码:
FBSDKShareOpenGraphObject *object = [[FBSDKShareOpenGraphObject alloc] objectWithProperties:properties];
尝试使用SWIFT实现相同功能时,我找不到
objectWithProperties
。有人可以帮忙吗?
最佳答案
Swift使用[NSObject : AnyObject]!
而不是NSDictionary
。在FBSDKShareOpenGraphObject的初始化中,objectWithProperties
变为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)