I'm using facebook sdk to implement a facebook login to my app. In the viewcontroller where I implement the login I also do a facebook graphrequest which allows me to get information about the current user.
The code for this graph request is:
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if error != nil {
//handle error
println("graphrequest error")
} else {
self.firstName = result.valueForKey("first_name") as? String
}
})
The user information comes back from the closure as the "result" paramater which can then be decomposed into its components ie firstname as above.
I know I can pass the first name value (and all other values individually) from this viewcontroller to the next. My question is (for efficiency) how can I pass the actual "result" itself (which contains all the user data) between viewcontrollers?
To pass it I figured I have to know its TYPE, looking at the facebook sdk info I thought I'd discovered the type is a FBSDKLoginManagerLoginResult but when I pass this to the next viewcontroller it shows up as nil. During debugging I PO'd the result and ended up with the following (a fake test user)
Printing description of result:
{
email = "wvjuyaz_greenestein_1428614609@tfbnw.net";
"first_name" = Barbara;
gender = female;
id = 1391655294490653;
"last_name" = Greenestein;
link = "http://ift.tt/1GQyFYd";
locale = "en_US";
"middle_name" = Amichehgcdjh;
name = "Barbara Amichehgcdjh Greenestein";
timezone = 0;
"updated_time" = "2015-04-09T21:23:30+0000";
verified = 0;
}
What type is this? and how do I pass it (in full) to the next viewcontroller?
Aucun commentaire:
Enregistrer un commentaire