Facebook friends list in swift

1.1k views Asked by At

I want a list of other Facebook friends that have logged into my app, but the code below is not working. I know I have other friends on the app but all it prints is "data(); totalCount(796);" Why is data always empty?

let params = ["fields": "id, first_name, last_name, middle_name, name, email, picture"]
    let request = FBSDKGraphRequest(graphPath: "me/friends", parameters: params)
    request!.start { (connection, result, error) -> Void in

        if error != nil {
            print(error!)
        }
        else if result != nil{
            print(result!)
        }
    }
1

There are 1 answers

0
Joseph Farah On BEST ANSWER

You haven't given much code, but it looks like you are forgetting to cast your data array after you've retrieved the information. It's kind of hard to tell without looking at your other code, but you might find this answer useful.

Here is an example of proper data casting and retrieval.

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
    let cell = tableView.cellForRowAtIndexPath(indexPath) as YourCell
    //cell.value, cell.text, cell.randomValue or whatever you need
}