如何在Swift中打开新的FBSession?我目前有一个Facebook登录工作正常,现在我想让一个新控制器中的朋友。
我目前有这个:
var friendsRequest : FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
println("dict: \(resultdict)")
var data : NSArray = resultdict.objectForKey("data") as NSArray
for i in 0...data.count {
let valueDict : NSDictionary = data[i] as NSDictionary
let id = valueDict.objectForKey("id") as String
println("id \(id)")
}
var friends = resultdict.objectForKey("data") as NSArray
println("\(friends.count) friends")
}
这给了我这个错误:
FBSDKLog:对端点' me / friends'的请求出错:必须为此端点的呼叫指定一个开放的FBSession。
我怎样才能做到这一点?我似乎无法找到这个......
答案 0 :(得分:0)
var friendsRequest : FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
println("Result Dict: \(resultdict)")
var data : NSArray = resultdict.objectForKey("data") as NSArray
for i in 0...data.count {
let valueDict : NSDictionary = data[i] as NSDictionary
let id = valueDict.objectForKey("id") as String
println("the id value is \(id)")
}
var friends = resultdict.objectForKey("data") as NSArray
println("Found \(friends.count) friends")
}