ObjectId가 함께 구문 분석에 테이블이 전무는 반환 | 인비터 (포인터) | 활성 (Bool) | createdAt (date)
Inviter 정보가있는 테이블을 채우려고합니다. 그래서 쿼리 중에 포인터를 가져 오려고합니다.
여기서 I는 tableData 어레이로부터의 데이터를 호출하고 여기서 다음이 데이터를
- (void) getInvitationsForLoggedInUser {
NSLog(@"entered getInvitationsForLoggedInUser");
PFQuery *postQuery = [PFQuery queryWithClassName:@"Connection"];
[postQuery whereKey:@"Active" equalTo:[NSNumber numberWithBool:NO]];
[postQuery includeKey:@"Inviter"];
[postQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
[self.tableData addObjectsFromArray:objects];
NSLog(@"InvitationViewController - Loaded %lu connection objects from Parse for logged in user", (unsigned long)[objects count]);
[self.invitationTableView reloadData];
} else {
NSLog(@"InvitationViewController - Could not find any connection objects from Parse");
}
}];
}
당긴 인 방법이다. 그냥 완전성에 대한
- (InvitationCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//TOFIX: In the view, I am seeing the entry but the fields are null. Need to check that the cell fields are getting populated.
static NSString *cellIdentifier = @"Identifier";
InvitationCell *cell = (InvitationCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// Create a new PFObject Object
PFObject *connection = nil;
connection = [self.tableData objectAtIndex:[indexPath row]];
PFObject *inviterCodeName = [connection objectForKey:@"Inviter"];
if (inviterCodeName == nil) {
NSLog(@"Error: Could not retrieve 'Inviter' object from connection object with id %@", [connection objectId]);
}
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[dateFormatter setLocale:enUSPOSIXLocale];
[dateFormatter setDateFormat:@"EEE, MMM, h:mm a"];
cell.dateLabel.text = [dateFormatter stringFromDate:[connection updatedAt]];
cell.codeName.text = [NSString stringWithFormat:@"Inviter Code Name: %@", inviterCodeName[@"codeName"]];
if (inviterCodeName[@"description"] == nil) {
cell.codeNameDescription.text = @"";
} else {
cell.codeNameDescription.text = [NSString stringWithFormat:@"%@", inviterCodeName[@"description"]];
}
return cell;
}
, 이는 모든 cellForRowAtIndexPath에, 내가 성공적으로 연결 개체를 검색하고, 지금이 수명주기 방법
- (void) viewWillAppear:(BOOL)animated {
[self getInvitationsForLoggedInUser];
[super viewWillAppear:animated];
[self.invitationTableView reloadData];
}
호출됩니다. "inviterCodeName"개체를 가져 오려고하면 항상 nil입니다.
테이블을 테스트하는 동안 이러한 요구 사항을 충족하는 행이 하나 뿐이며 성공적으로 채워집니다.
제안 사항?
"이 테스트를 수행하는 동안 테이블에 하나의 행만 있고이 요구 사항을 충족하며 성공적으로 채워집니다."라는 의미입니다. 또한,'viewWillAppear' 메쏘드의'[self.invitationTableView reloadData];는'findObjectsInBackgroundWithBlock'이 완료되기 전에 (즉, 아직 데이터가 없으므로 아직 테이블을 업데이트하지 않습니다.) 호출됩니다. – bobnoble
기준에 맞는 쿼리를 얻는 테이블에 행이 있습니다. reloadData를 viewWillAppear 밖으로 옮겨 보자. – envinyater
같은 문제는 불행히도 :( – envinyater