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

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -