[英]Retrieving Profile Picture iOS Parse.com
I'm having an issue retrieving the a profile picture from a PFFile column in the Parse User class. 我在从Parse User类的PFFile列中检索配置文件图片时遇到问题。 I read in the docs that you need to use the
PFUser
object to query the User
class. 我在文档中读到您需要使用
PFUser
对象来查询User
类。 Right now no image is showing up. 现在没有图像出现。 Here is my code:
这是我的代码:
PFUser *user = [PFQuery getUserObjectWithId:[PFUser currentUser].objectId];
[user fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
_profileImage.file = [object objectForKey:@"profilePicture"];
}];
(1) The current user's PFUser object is in fact [PFUser currentUser] so all that code in your first line could be replaced with: (1)当前用户的PFUser对象实际上是[PFUser currentUser],因此第一行中的所有代码都可以替换为:
PFUser *user = [PFUser currentUser];
(2) Everything else looks OK, but if you're using a PFImageView, your [profileImage loadInBackground]; (2)其他一切看起来都不错,但是如果你正在使用PFImageView,你的[profileImage loadInBackground]; call should also be within the fetchIfNeededInBackgroundWithBlock: async block.
call也应该在fetchIfNeededInBackgroundWithBlock:async块中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.