我从我的数据库(firebase)获取用户个人资料名称/组名...所以最初,我只是通过解析我的objectId属于我正在寻找的用户,但现在我正在混合ups我正在为用户类人员展示小组成员图片......
拥有第一个数据库的JSON
"-KCvEE45IoE1AjDbnRK7" : {
"counter" : 0,
"date" : "2016-03-17T19:24:21",
"description" : "Travis Tubbs",
"groupId" : "js837yUMs0xIClIaB3Lb",
"lastMessage" : "AwG1wCdnaYSm+GmeX5K7QV3qNKKBQdTtnY7rVwaFDrgHjB9viH5husSJRAk6SNIMCMMKAsFUhSgT/eJmwM04hZzwoVQc1RqqnC9vV91qAhUGVw==",
"members" : [ "js837yUMs0", "xIClIaB3Lb" ],
"password" : "h6vfwBTeju",
"profileId" : "js837yUMs0",
"recentId" : "-KCvEE45IoE1AjDbnRK7",
"type" : "private",
"userId" : "xIClIaB3Lb"
},
"-KCvSmzlpADYmTsYMzCl" : {
"counter" : 0,
"date" : "2016-03-17T19:26:13",
"description" : "CNN",
"groupId" : "KfMfFI9VXe",
"lastMessage" : "AwHjItVn04SHxR3v281XlAm/KUzs8NGv+09OxWRfkkVO1ibeTUpAmSpiw5amQaI+GP3+1tIqPnAzpWyonE6BlsROs/Mx6zTLr3dzEZWwxq8Rgg==",
"password" : "inQTldUXaZ",
"profileId" : "js837yUMs0",
"recentId" : "-KCvSmzlpADYmTsYMzCl",
"type" : "group",
"userId" : "js837yUMs0"
},
这是我的解析查询
if([recent[@"type"] isEqual: @"private"]) {
PFQuery *query = [PFQuery queryWithClassName:PF_USER_CLASS_NAME];
[query whereKey:PF_USER_OBJECTID equalTo:recent[@"profileId"]];
[query setCachePolicy:kPFCachePolicyCacheThenNetwork];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
{
if (error == nil)
{
PFUser *user = [objects firstObject];
[AFDownload start:user[PF_USER_PICTURE] complete:^(NSString *path, NSError *error, BOOL network)
{
if (error == nil) imageUser.image = [[UIImage alloc] initWithContentsOfFile:path];
}];
}
}];
}
if([recent[@"type"] isEqual: @"group"])
{
PFQuery *query2 = [PFQuery queryWithClassName:PF_GROUP_CLASS_NAME];
[query2 whereKey:PF_GROUP_NAME equalTo:recent[@"description"]];
[query2 setCachePolicy:kPFCachePolicyCacheThenNetwork];
[query2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
{
if (error == nil)
{
PFUser *group = [objects firstObject];
[AFDownload start:group[PF_GROUP_LOGO] complete:^(NSString *path, NSError *error, BOOL network)
{
if (error == nil) imageUser.image = [[UIImage alloc] initWithContentsOfFile:path];
}];
}
}];
}
再次,似乎我有一个逻辑问题,因为我可以说我有一个组“Foo”有时它会显示用户“Roger Waters”的图片或者同样,组“Bar”会有它的图片显示作为组“espn”的图片
答案 0 :(得分:0)
我发现了我的代码问题......
这既不是逻辑错误也不是缓存错误......
这是两个不同的工件,我有一个值存在于我的一个数据库中,但它在我的其他数据库中不存在,所以它只是在我的云代码中发送一个空值并且打破了以至于我不是&# 39;看到错误的应用程序方面。