swift - How can I call this function in viewDidLoad() in iOS8 -
i want call function in viewdidload
don't know how 1 this. can please me?
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 , logged in through facebook!") self.fetchuserinforfromfacebook(withcompletionhandler) println("user logged in through facebook!") withcompletionhandler(success: true) } } else { println("uh oh. user cancelled facebook login.") self.showerrormessage(error!) withcompletionhandler(success: false) } }) }
override func viewdidload() { super.viewdidload() self.loginwithfacebook { (success) -> () in if success { //succeeded } else { //failed } } } }
Comments
Post a Comment