我正在使用Parse.com從數據庫中檢索我需要的數據。PFRelation with CurrentUser在TableView中的帖子
在我的tableview中,我有一個圖像根據這個查詢調用帶有顯示的帖子的CurrentUser的報告的顏色。
-(void)QueryForUpVote {
PFQuery *QueryForUpVotePost = [PFQuery queryWithClassName:FF_POST_CLASS];
[QueryForUpVotePost whereKey:@"UP_Vote" equalTo:[PFUser currentUser]];
[QueryForUpVotePost findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
UpVoteCurrentUser = [[NSMutableArray alloc] init];
for (PFObject *ObjectForUpVote in objects) {
[UpVoteCurrentUser addObject:ObjectForUpVote];
}
[self.FFTableView reloadData];
}
}];
}
在泰伯維我加入這個以確保如果有具有與CurrentUser的關係(像一種社交網絡)後
if ([[PFUser currentUser] objectForKey:@"UP_Vote"]) {
CellaIMG.MedalCount.image = [UIImage imageNamed:@"FFIMG_Medal_Blu"];
CellaIMG.AddGoPoint.tag = indexPath.row;
[CellaIMG.AddGoPoint addTarget:self action:@selector(AddGoPointAction:) forControlEvents:UIControlEventTouchUpInside];
} else {
CellaIMG.MedalCount.image = [UIImage imageNamed:@"FFIMG_Medal"];
CellaIMG.AddGoPoint.tag = indexPath.row;
[CellaIMG.AddGoPoint addTarget:self action:@selector(DecrementGoPoint:) forControlEvents:UIControlEventTouchUpInside];
}
我現在的問題是,TableView中無法識別CurrentUser與帖子顯示的關係...當用戶與帖子有特定關係時,我提供的圖片應該變成灰色到藍色......我在哪裏做錯了?
的MutableArray在使用:
- (void)AddGoPointAction:(id)sender {
PFObject *AddGoPointToPost = [self.UpVoteCurrentUser objectAtIndex:[sender tag]];
[AddGoPointToPost incrementKey:FF_POST_GOPOINTPOST byAmount:[NSNumber numberWithInt:1]];
PFRelation *RelationForVote = [AddGoPointToPost relationforKey:@"UP_Vote"];
[RelationForVote addObject:[PFUser currentUser]];
[AddGoPointToPost saveInBackground];
[self.FFTableView reloadData];
}
- (void)DecrementGoPoint:(id)sender {
PFObject *AddGoPointToPost = [self.UpVoteCurrentUser objectAtIndex:[sender tag]];
[AddGoPointToPost incrementKey:FF_POST_GOPOINTPOST byAmount:[NSNumber numberWithInt:-1]];
PFRelation *RelationForVote = [AddGoPointToPost relationforKey:@"UP_Vote"];
[RelationForVote removeObject:[PFUser currentUser]];
[AddGoPointToPost saveInBackground];
[self.FFTableView reloadData];
}
你總是看到所有的藍色或灰色?第二塊代碼在哪裏?你在哪裏使用'UpVoteCurrentUser'? – Wain
圖像始終是灰色的並且upvote ...是包含我在我的應用程序中指定的查詢結果的數組 – kAiN
我編輯了我的問題以向您展示使用數組的位置 – kAiN