iosswiftfbrequest-form

How can I retrieve friend's picture through FBRequest in swift


var friendRQ: FBRequest = FBRequest(forGraphPath: "me/taggable_friends?fields=name,picture.width(66).height(66)")

    friendRQ.startWithCompletionHandler({ (Connection, results, error) -> Void in
            self.FBData = results.objectForKey("data") as NSMutableArray
            println(self.FBData)
        })

I have no problem on retrieve the name, but picture.

FBData.picture reutrns a NSURL

picture =         {
        data =             {
            height = 68;
            "is_silhouette" = 0;
            url = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/v/t1.0-1/c9.0.68.68/p68x68/10410849_1410555062563816_XXXXX70293207008499_n.jpg?oh=ddd9e2d36cc13bc0095b243097a199b4&oe=54FC0162&__gda__=1427125899_dc78acc5e14b7d25aee153ccf8bb1543";
            width = 68;
        };
    };

how can I show this picture properly in an ImageView?

    var picture: NSURL = FBFriendHelper.sharedInstance.FBData[indexPath.row].picture
    var data: AnyObject? = picture.valueForKey("data")

and then?


Solution

  •     var FBpicture: NSURL = FBHelper.sharedInstance.FBData[indexPath.row].picture
        var url: NSURL = NSURL(string: String(FBpicture.valueForKey("data")?.url! as NSString) as String)!
        var picData: NSData = NSData(contentsOfURL: url)!
        cell.FBProfile.image = UIImage(data: picData)
    

    I found the solution of mine code