[英]Does this store the objects as an array? parse.com
我想知道我的代码是否在parse.com中获取一个数组并将其正确添加到我的NSMutableArray中。
在ViewdidLoad中:
self.alreadySharedWith = [NSMutableArray array];
//detailId contains the current posts objectId.
PFQuery *currentPostSharedWith = [PFQuery queryWithClassName:@"Posts"];
[currentPostSharedWith getObjectInBackgroundWithId:detailId block:^(PFObject *object, NSError *error) {
self.alreadySharedWith = [NSMutableArray arrayWithObjects:object[@"sharedWithUsers"], nil];
NSLog(@"These are already shared: %@", self.alreadySharedWith);
}];
它的作用是:获取与当前用户的帖子共享的所有用户的objectId。 (当前用户可以与其他用户分享信息)
MY NSLog显示以下内容:
这些已经共享:((Vf5zOl2DiR,LMiQK016A5,2O906caJgJ))
但是,当我尝试检查Vf5zOl2DiR是否已存在于我的sharedShare中时,没有任何结果。 为什么会这样?
我如何检查对象数组。
- (void)checkArray:(id)sender{
if ([self.alreadySharedWith containsObject:@"Vf5zOl2DiR"]) {
NSLog(@"Found it!");
}
}
我的日志未显示任何内容。
似乎您在填充self.alreadySharedWith
时将数组放入数组中。 也许尝试更改(在viewDidLoad
)
self.alreadySharedWith = [NSMutableArray arrayWithObjects:object[@"sharedWithUsers"], nil];
至
self.alreadySharedWith = (NSMutableArray *)object[@"sharedWithUsers"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.