I am new in iOS app development and I'm having a hard time trying to pass facebook user information between views. My app has 2 views. I was able to implement facebook login using this tutorial because as you might know they still dont give oficial support to swift.
This is my view controller:
// ViewController.swift
import UIKit
class ViewController: UIViewController, FBLoginViewDelegate{
@IBOutlet var fbLoginView : FBLoginView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.fbLoginView.delegate = self
self.fbLoginView.readPermissions = ["public_profile", "email", "user_friends"]
}
// FACEBOOK DELEGATE METHODS
func loginViewShowingLoggedInUser(loginView : FBLoginView!) {
println("User Logged In")
println("This is where you perform a segue.")
self.performSegueWithIdentifier("gotoMenu", sender: self)
}
func loginViewFetchedUserInfo(loginView : FBLoginView!, user: FBGraphUser){
println(user.name)
}
func loginViewShowingLoggedOutUser(loginView : FBLoginView!) {
println("User Logged Out")
}
func loginView(loginView : FBLoginView!, handleError:NSError) {
println("Error: \(handleError.localizedDescription)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
This is the second view controller:
// SecondViewController.swift
import UIKit
class SecondViewController: UIViewController {
@IBOutlet weak var greeting: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I need to show the user name in the second view and if possible his profile picture. How can I do this?
Thanks you very much Greeting nick