我想调用这个函数,viewDidLoad
但我不知道怎么做。你能帮我么?
func loginWithFacebook(withcompletionHandler: (success:Bool) ->()){
var permissions : Array = [ "user_location","public_profile"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
println("User SIGNED UP and logged in through Facebook!")
self.fetchUserInforFromFacebook(withcompletionHandler)
println("User logged in through Facebook!")
withcompletionHandler(success: true)
}
} else {
println("Uh oh. The user cancelled the FACEBOOK LOGIN.")
self.showErrorMessage(error!)
withcompletionHandler(success: false)
}
})
}