gpt4 book ai didi

swift - FBSDKGraphRequest 注册 Parse 用户是 "ambiguous?"

转载 作者:行者123 更新时间:2023-11-30 13:43:03 26 4
gpt4 key购买 nike

教程应用程序的 SignUpViewController 中使用的 FBSDKGraphRequest 连接处理程序现已过时。我将其更新到在用户成功注册后尝试放置解析代码之前不会出错的程度。一旦我输入解析代码(使用 FB SDK 结果注册用户),我就会收到错误“表达式类型在没有更多上下文的情况下不明确”。

这是我到目前为止所拥有的:

    let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, gender, email"])
graphRequest.startWithCompletionHandler ({ connection, result, error in
if error != nil {
//onError()
print(error)
return
} else {
let fbResult = result as! Dictionary<String, AnyObject>
print("FbResult \(fbResult)")

PFUser.currentUser()?["gender"] = result["gender"]
PFUser.currentUser()?["name"] = result["name"]

try PFUser.currentUser()?.save()

let userId = result["id"] as! String
let facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "/picture?type=large"

if let fbpicUrl = NSURL(string: facebookProfilePictureUrl) {

if let data = NSData(contentsOfURL: fbpicUrl) {

self.profilePic.image = UIImage(data: data)

let imageFile:PFFile = PFFile(data: data)!

PFUser.currentUser()?["image"] = imageFile

try PFUser.currentUser()?.save()
}
})

出于某种原因,XCode 讨厌“print fbresult”行之后的任何内容。这是解析代码之前的工作代码的粘贴:

http://pastebin.com/dUyEvYmr

如何更新它以接受解析代码?

谢谢!!

PS:我可以确认我拥有最新的 Parse 和 FB SDK。我正在运行最新版本的 XCode (7.2.1)。

最佳答案

我在参加 udemy swift 类(class)时也遇到了同样的问题。

我的解决方案是:

if let fbResult = {
...
let name : NSString = (fbResult.valueForKey("name") as? NSString)!
let gender : NSString = (fbResult.valueForKey("gender") as? NSString)!
...
}

希望它对您有用!

关于swift - FBSDKGraphRequest 注册 Parse 用户是 "ambiguous?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35327406/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com