Why is this giving me a error?
fatal error: unexpectedly found nil while unwrapping an Optional value
Am I using the wrong valueForKey
String
? I want to get the list of friends. (There are friends because when I print result it shows them)
let fbRequest = FBSDKGraphRequest(graphPath:"/me/friends", parameters: nil);
fbRequest.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
if error == nil {
let userName : NSArray = result.valueForKey("name") as! NSArray
print("Friends are : \(result)")
} else {
print("Error Getting Friends \(error)");
}
}