PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] How to unwrap an callback in swift?

 July 16, 2022     facebook-login, optional, swift, xcode     No comments   

Issue

I'm using FB Login for my app in Swift and when I make a graph request, it returns the following result:

Optional({
    email = "arjun.ramjams@gmail.com";
    id = 10218497873670001;
    name = "Arjun Ram";
})

Now, how should I read, each individual value(i.e: email, id and name)?


Solution

func fetchProfile() {
        let parameters = ["fields": "id,email, first_name, last_name"]
        GraphRequest(graphPath: "me",parameters: parameters).start{(connection, user, Err) in
            if Err != nil {
                print(Err!)
                return

            }
            let dic = user as! NSDictionary
            let userID = dic["id"] as! String
            let Email = dic["email"] as! String
            let fname = dic["first_name"] as! String
            let lname = dic["last_name"] as! String

        }

}


Answered By - Shubhendu Devmurari
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing