我有一些代码需要很长时间才能加载,我想加快速度。
我的最终目标是通过 ID 数组获取对象列表。
现在我正在遍历我的 id 字符串数组,并构建用户对象以附加到 whereKey,但想知道是否有更好的方法来做到这一点。
NSMutableArray *followingArray = [[NSMutableArray alloc] init];
for (NSString *userId in c_user.following) {
PFQuery *getUser = [FSUser query];
FSUser *user = (FSUser *)[getUser getObjectWithId:userId];
[followingArray addObject:user];
}
[query whereKey:@"owner" containedIn:followingArray];
最佳答案
编辑:您可以做的是使用用户 objectId 构建一个指针,然后查询它。
NSMutableArray* followingArray = [[NSMutableArray alloc] init];
for (NSString* userId in c_user.following) {
// build the pointer to the object
PFObject* object = [PFObject objectWithClassName:@"_User"];
object.objectId = userId;
[followingArray addObject:object];
}
[query whereKey:@"owner" containedIn:followingArray];
关于ios - 在 Parse 中,我如何编写一个查询来为我提供带有 id 列表的所有对象?操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32052924/