如何在String类型的变量中从闭包中存储常量的值?

时间:2022-05-04 03:44:43

I am creating an app in which I am posting my post to Facebook from my app in which they provide me a postID now this postID is a constant and its in closure now I had to convert this postID in variable of type String and store that postID in my database. 如何在String类型的变量中从闭包中存储常量的值?

我正在创建一个应用程序,我在我的应用程序中将我的帖子发布到Facebook,其中他们为我提供了一个postID现在这个postID是一个常量并且它在关闭现在我必须将此postID转换为String类型的变量并存储该postID在我的数据库中。

And when I print my result it shows like the below image I think this is a dictionary and I don't know how to convert it into string. If anyone can help.Below code used for posting:

当我打印我的结果它显示如下图像我认为这是一个字典,我不知道如何将其转换为字符串。如果有人可以提供帮助。用于发布的代码:

if (FBSDKAccessToken.currentAccessToken() != nil){
                if FBSDKAccessToken.currentAccessToken().hasGranted("publish_actions") {
                    FBSDKGraphRequest(graphPath: "me/feed", parameters: ["message": "Task: \(self.textField.text!)\n Task Description: \(self.textAreaDescription.text!)\n Time: \(self.dateTime)\n Location: \(self.placemark!.locality!) \(self.placemark!.administrativeArea!)"], HTTPMethod: "POST").startWithCompletionHandler({
                        (connection, result, error) -> Void in
                        if (error != nil) {
                            // Do nothing
                        } else {
                            print("postID: \(result)")

                        }
                    })
                }
            }

1 个解决方案

#1


0  

try

if let dic = result as? Dictionary<String, AnyObject> {
    let id = dic["id"]
}

#1


0  

try

if let dic = result as? Dictionary<String, AnyObject> {
    let id = dic["id"]
}