Reputation: 27
I have 2 custom UITableViewCell
, and both have properties.
Although NSLog(@"%@", cell.class)
shows that both are being created correctly, I can't set my properties on tableView:cellForRowAtIndexPath:
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (indexPath.row != [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:RealtyCellIdentifier];
NSLog(@"%@", cell.class);
cell.realtyNameLabel.text = [[self.realties objectAtIndex:indexPath.row] adTitle];
cell.realtyPriceLabel.text = [NSString stringWithFormat:@"R$%ld", [[self.realties objectAtIndex:indexPath.row] price]];
}
if (indexPath.row == [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:LoadMoreCellIdentifier];
NSLog(@"%@", cell.class);
}
return cell;
}
@import UIKit;
@interface IGBRealtyCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *realtyImageView;
@property (weak, nonatomic) IBOutlet UILabel *realtyNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *realtyPriceLabel;
@end
What am I missing?
Upvotes: 0
Views: 1742
Reputation: 1095
You are using UITableViewCell
instead of IGBRealtyCell
. Try casting it to IGBRealtyCell variable.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (indexPath.row != [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:RealtyCellIdentifier];
IGBRealtyCell *realtyCell = (IGBRealtyCell*)cell;
NSLog(@"%@", cell.class);
realtyCell.realtyNameLabel.text = [[self.realties objectAtIndex:indexPath.row] adTitle];
realtyCell.realtyPriceLabel.text = [NSString stringWithFormat:@"R$%ld", [[self.realties objectAtIndex:indexPath.row] price]];
}
if (indexPath.row == [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:LoadMoreCellIdentifier];
IGBRealtyCell *realtyCell = (IGBRealtyCell*)cell;
NSLog(@"%@", realtyCell.class);
}
return cell;
}
Upvotes: 1