에 내 사용자 지정 셀의 IBOutlets에 액세스 할 수 없습니다 이 방법은 다음 D에 cell.tweetText.text = [tweets objectAtIndex:indexPath.row];
에은 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;
}
Xcode는 cell
이후에 'TWCustomCell *'유형의 객체에서 'tweetText'속성을 찾을 수 없습니다. tweetText '에 액세스하려고 했습니까? "라고 묻고, cell->tweetText.text
으로 바꾸라고 알려줍니다."시맨틱 문제 : 인스턴스 변수'tweetText '가 보호되어 있습니다. "
당신을 – Basel
다른 객체의 인스턴스 변수를 쓰레기와 janky입니다. 그것들을'@ public'으로 선언하는 것은 좋은 이유 때문에 디폴트로 비활성화되어있는 것을 활성화시키는 반창고입니다. 대신 ('@ property')를 선언하고 대신에 속성 ('.'이 아니라'-')을 사용해야합니다. –