AFNetworking を使用して MySQL データベースからデータを取得しています。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
現在ログインしているユーザーがMySQLのフィールド「作成者」と等しいかどうかを確認するコードがあります。エントリは表示されますが、空のセルを非表示にしたいです。
if ([creator isEqual: userID]) {
[cell.contentView addSubview:imageView];
cell.textLabel.text = [[NSString alloc] initWithFormat:@" %@",[tempDictionary objectForKey:@"team_name"]];
cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%@ %@ \n%@", [tempDictionary objectForKey:@"date"], [tempDictionary objectForKey:@"time"], [tempDictionary objectForKey:@"location"]];
} else {
[imageView removeFromSuperview];
cell.textLabel.text = nil;
cell.detailTextLabel.text = nil;
}
UITableView は、選択したフィールドのデータを表示しているだけでなく、他のすべての空のセルも表示しています (まだ配列をカウントしているため)。