gpt4 book ai didi

ios - 解析 iOS - 如何从另一个类查询 PFUser 详细信息

转载 作者:行者123 更新时间:2023-11-28 19:00:43 26 4
gpt4 key购买 nike

我正在尝试为我的 iOS 社交应用程序编写一个 Parse 查询,它将显示所有关注活跃用户的用户。这是我目前所拥有的:

PFQuery *followingUser = [PFQuery queryWithClassName:@"Activity"];
[followingUser whereKey:@"Activity" equalTo:@"follow"];
[followingUser whereKey:@"fromUser" equalTo:self.user];
[followingUser includeKey:@"User"];
[followingUser setCachePolicy:kPFCachePolicyCacheThenNetwork];

目前,这正确地为我提供了跟随任何其他用户的事件用户的所有记录,但这并没有为我提供相应记录的 PFUser 详细信息(用户个人资料图片、显示名称等)。关于如何在一个查询中轻松提取 PFUser 详细信息的任何想法?

提前致谢

最佳答案

这是我用来获取所有被关注用户、被关注用户的所有帖子以及当前用户的所有帖子的查询示例代码。希望对您有所帮助!

// List of all users being followed by current user
PFQuery *followingActivitiesQuery = [PFQuery queryWithClassName:kFTActivityClassKey];
[followingActivitiesQuery whereKey:kFTActivityTypeKey equalTo:kFTActivityTypeFollow];
[followingActivitiesQuery whereKey:kFTActivityFromUserKey equalTo:[PFUser currentUser]];
followingActivitiesQuery.cachePolicy = kPFCachePolicyNetworkOnly;
followingActivitiesQuery.limit = 100;

// Posts from users being followed
PFQuery *postsFromFollowedUsersQuery = [PFQuery queryWithClassName:self.parseClassName];
[postsFromFollowedUsersQuery whereKey:kFTPostUserKey matchesKey:kFTActivityToUserKey inQuery:followingActivitiesQuery];
[postsFromFollowedUsersQuery whereKey:kFTPostTypeKey containedIn:@[kFTPostTypeImage,kFTPostTypeVideo,kFTPostTypeGallery]];

// Posts from current user
PFQuery *postsFromCurrentUserQuery = [PFQuery queryWithClassName:self.parseClassName];
[postsFromCurrentUserQuery whereKey:kFTPostUserKey equalTo:[PFUser currentUser]];
[postsFromCurrentUserQuery whereKey:kFTPostTypeKey containedIn:@[kFTPostTypeImage,kFTPostTypeVideo,kFTPostTypeGallery]];

PFQuery *query = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects: postsFromFollowedUsersQuery, postsFromCurrentUserQuery, nil]];
[query includeKey:kFTPostUserKey];
[query orderByDescending:@"createdAt"];

关于ios - 解析 iOS - 如何从另一个类查询 PFUser 详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26150007/

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