【发布时间】:2015-10-12 22:47:33
【问题描述】:
我正在实施保存帖子部分,该帖子在保存以显示在主页上时包含用户个人资料图片。但是会有一个没有个人资料图片的用户。我试了这段代码,出现错误。
if let profilePicture = PFUser.currentUser()?.objectForKey("profile_picture") {
post["profile_picture"] = profilePicture
} else {
post["profile_picture"] = UIImage(named: "AvatarPlaceholder" )
}
post.saveInBackgroundWithBlock({ ( isSucessful: Bool, error : NSError?) -> Void in
if error == nil {
self.alert("success", message : "your post has been uploaded")
} else {
self.alert("Error", message : (error?.localizedDescription)!)
}
如果用户有头像,那就没问题了。但如果不是,那就是问题所在。
我在资产中有 Avatarplaceholder jpeg 文件。
我的问题是.....
如何上传我的 avatarplaceHolder ?
或者有没有更好的方法来覆盖 nil 值?,
其实我不想浪费我的云存储。
【问题讨论】:
标签: swift parse-platform uiimage