gpt4 book ai didi

swift - NSInvalidArgumentException 与 FBSDKGraphRequest

转载 作者:可可西里 更新时间:2023-11-01 01:40:49 28 4
gpt4 key购买 nike

我收到以下异常:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary imagePathForPictureMode:size:]: unrecognized selector sent to instance 0x7ff9f8d25d10'

使用此代码:

PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, block: {
(user: PFUser?, error: NSError?) -> Void in

if let user = user {
if user.isNew {
var request = FBSDKGraphRequest(graphPath: "me", parameters: nil)
request.startWithCompletionHandler({
(connection, result, error) -> Void in

if error == nil {
// exception thrown next line
let strProfilePicURL = result.imagePathForPictureMode(FBSDKProfilePictureMode.Square, size: self.profileImage.frame.size)
let url = NSURL(string: strProfilePicURL, relativeToURL: NSURL(string: "http://graph.facebook.com/"))
let imageData = NSData(contentsOfURL: url!)
let image = UIImage(data: imageData!)

self.profileImage.image = image!
}
})
println("User signed up and logged in through Facebook!")
} else {
println("User logged in through Facebook!")
}
} else {
println("Uh oh. The user cancelled the Facebook login.")
}
})

这里为什么会抛出异常?我也试过:

let size = self.profileImage.frame.size as CGSize
let strProfilePicURL = result.imagePathForPictureMode(FBSDKProfilePictureMode.Square, size: size)

最佳答案

currentProfile 是在 SDK 获得访问 token 后异步获取的,因此根据您请求 currentProfile 的时间,它可能为 nil。

您还可以在配置文件更新时观察 FBSDKProfileDidChangeNotification。参见 https://developers.facebook.com/docs/reference/ios/current/class/FBSDKProfile/

关于swift - NSInvalidArgumentException 与 FBSDKGraphRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29978717/

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