Я сделал пользовательскую ячейку с XIB: .h
#import <UIKit/UIKit.h>
@interface TWCustomCell : UITableViewCell {
IBOutlet UILabel *nick;
IBOutlet UITextView *tweetText;
}
@end
.m
#import "TWCustomCell.h"
@implementation TWCustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
И я загружаю их в cellForRowAtIndexPath:
следующим образом:
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TWCustomCell *cell = (TWCustomCell*)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObject = [[NSBundle mainBundle] loadNibNamed:@"TWCustomCell" owner:nil options:nil];
for (id currentObject in topLevelObject) {
if([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (TWCustomCell*) currentObject;
break;
}
}
}
// Configure the cell...
cell.tweetText.text = [tweets objectAtIndex:indexPath.row];
return cell;
}
Вкл. cell.tweetText.text = [tweets objectAtIndex:indexPath.row];
В точке после cell
XCode сообщает мне_ "Свойство 'tweetText' не найдено для объекта типа 'TWCustomCell *'; Вы имели в виду доступ к ivar 'tweetText'?"и говорит мне заменить его на cell->tweetText.text
.Но появляется ошибка: «Семантическая проблема: переменная экземпляра tweetText защищена».Что мне делать?