我必须将客观的c代码转换为swift3.0,我在尝试在线转换时遇到错误

时间:2017-03-15 11:59:26

标签: swift3 fbsdk fbsdksharekit

NSURL *contentURL = [[NSURL alloc] initWithString: @"http://en.wikipedia.org/wiki/Facebook"];

NSURL *imageURL = [NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];

button.shareContent = [[FBSDKShareLinkContent alloc]
                        initWithContentURL: contentURL
                              contentTitle: @"My Share Title"
                        contentDescription: @"Lorem ipsum dolor sit amet."
                                  imageURL: imageURL
                                 peopleIDs: @[@"1561082740838259"]
                                   placeID: @"166793820034304"
                                       ref: @"myRefId"];

1 个答案:

答案 0 :(得分:1)

我在线转换没有问题(编译器只抱怨我没有定义FBSDKShareLinkContent:

func dummy(button: UIButton) {
    //  Converted with Swiftify v1.0.6276 - https://objectivec2swift.com/
    var contentURL = URL(string: "http://en.wikipedia.org/wiki/Facebook")
    var imageURL = URL(string: "http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg")
    button.shareContent = FBSDKShareLinkContent(contentURL: contentURL, contentTitle: "My Share Title", contentDescription: "Lorem ipsum dolor sit amet.", imageURL: imageURL, peopleIDs: ["1561082740838259"], placeID: "166793820034304", ref: "myRefId")

}

我添加了一个指向在线转换器的链接作为评论(实际上我只是将其保留,转换器添加它!)