无法符合FBSDKSharingDelegate

时间:2015-10-03 12:28:42

标签: ios swift facebook-ios-sdk

我无法将我的GameViewController与FBSDKSharingDelegate相符,我也不知道为什么。

这些是我认为需要的功能。

func sharer(sharer: FBSDKSharing, didCompleteWithResults results: [NSObject : AnyObject]) {
}
func sharer(sharer: FBSDKSharing, didFailWithError error: NSErrorPointer) {
}
func sharerDidCancel(sharer: FBSDKSharing) {
    NSLog("share cancelled")
}

我错过了什么吗?

提前谢谢!

3 个答案:

答案 0 :(得分:3)

解决。

func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject]) {
    print(results)
}

func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!) {
    print("sharer NSError")
    print(error.description)
}

func sharerDidCancel(sharer: FBSDKSharing!) {
    print("sharerDidCancel")
}

答案 1 :(得分:1)

以下解决了我的问题:

    public func sharerDidCancel(_ sharer: FBSDKSharing!) {

}


public func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Swift.Error!) {

}

public func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {

}

答案 2 :(得分:0)

以下是Swift 3的案例

/*!
     @abstract Sent to the delegate when the sharer is cancelled.
     @param sharer The FBSDKSharing that completed.
     */
    public func sharerDidCancel(_ sharer: FBSDKSharing!) {

    }

    /*!
     @abstract Sent to the delegate when the sharer encounters an error.
     @param sharer The FBSDKSharing that completed.
     @param error The error.
     */
    public func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {

    }

    /*!
     @abstract Sent to the delegate when the share completes without error or cancellation.
     @param sharer The FBSDKSharing that completed.
     @param results The results from the sharer.  This may be nil or empty.
     */
    public func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {

    }