Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: unexpectedly found nil while unwrapping an Optional value #47

Open
datomnurdin opened this issue Feb 27, 2015 · 0 comments

Comments

@datomnurdin
Copy link
Contributor

I'm doing bridging header but it throw an error message

fatal error: unexpectedly found nil while unwrapping an Optional value

My code

@IBAction func btnLinkedin(sender: AnyObject) {
if btnLinkedin.on {
client.getAuthorizationCode({ (code:String!) -> Void in
println(code)
self.client.getAccessToken(code, success: { (accessTokenData) -> Void in
if let dict = accessTokenData as? Dictionary<String, AnyObject> {
let accessToken: AnyObject? = dict["access_token"]
self.requestMeWithToken(accessToken!)
}
}, failure: { (error:NSError!) -> Void in
println("Quering accessToken failed (error)")
})
}, cancel: { () -> Void in
println("Authorization was cancelled by user")
}, failure: { (error:NSError!) -> Void in
println("Authorization failed (error)")
})
println("Switch is on")
btnLinkedin.setOn(true, animated:true)
} else {
println("Switch is off")
btnLinkedin.setOn(false, animated:true)
}
}

func requestMeWithToken(accessToken: AnyObject){
    client.GET("https://api.linkedin.com/v1/people/~?oauth2_access_token=%@&format=json", parameters: nil, success: { (operation:AFHTTPRequestOperation!, result:AnyObject!) -> Void in
        println("current user \(result)")
        }) { (operation: AFHTTPRequestOperation!, error:NSError!) -> Void in
        println("failed to fetch current user \(error)")
    }
}

Please advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant