我對於目標c是新手,並且我正在使用parse.com作爲社交媒體應用的數據庫。我想要做的是從我的POST表中抓取用戶的帖子。我使用指針從我的USER表中獲取用戶名,這很好,因爲您將在我的代碼中看到下面的內容,但是當我在將UILabel分配給用戶的帖子之前使用fetchifneeded時,我仍然收到此錯誤「關鍵「故事」沒有數據。在獲取其值之前調用fetchIfNeeded。「我感謝任何幫助,並感謝你的進步,如果我沒有讓我自己清楚,無論如何生病會更樂意擴大任何事情。在獲取其值之前需要解析調用獲取
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
if (indexPath.section == self.objects.count) {
UITableViewCell *cell = [self tableView:tableView cellForNextPageAtIndexPath:indexPath];
return cell;
}
static NSString *CellIdentifier = @"StoryCell";
NinetiesCell *cell = (NinetiesCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//for the post of the user
PFObject *user = object[@"User"];
[user fetchIfNeeded];
//get username from pointer
cell.userName.text = user[@"username"];
PFObject *story = [object objectForKey:@"Story"];
[story fetchIfNeeded];
cell.story.text = [object objectForKey:@"Story"];
// Configure the cell
NSDate *updated = [object createdAt];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EEE, MMM d, h:mm a"];
cell.dateLabel.text = [NSString stringWithFormat:@"%@", [dateFormat stringFromDate:updated]];
return cell;
}
你確定有關鍵'Story'的任何數據嗎? – Emil
是的,我有它的工作之前,我調整它有一個像按鈕。 – rjsantiago77
不應該是故事對象的'cell.story.text = story [@「text」]或其他值嗎?將PFObjext放入文本字段是沒有意義的 – Paulw11