Я получаю странную ошибку компиляции - я не знаю, есть ли «призрак в машине» или что?
Ниже, если фрагмент кода, в котором я получаю эту ошибку
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"User";
cell.detailTextLabel.text = @"John Smith";
break;
case 1:
cell.textLabel.text = @"From";
cell.detailTextLabel.text = @"12/01/2010";
break;
case 2:
cell.textLabel.text = @"To";
cell.detailTextLabel.text = @"12/02/2010";
break;
case 3:
cell.textLabel.text = @"Duration";
cell.detailTextLabel.text = @"30 Days";
break;
case 4:
UITextView *commentsView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
//commentsView.layer.cornerRadius = 10.0f;
//[cell.contentView addSubview:commentsView];
//[commentsView release];
break;
default:
break;
}
} else if (indexPath.section == 1) {
cell.detailTextLabel.text = @"Approve";
} else {
cell.detailTextLabel.text = @"Reject";
}
// Configure the cell...
return cell;
}
, я получаю следующую ошибку
/Users/dk/Desktop/xxx/Classes/DetailedLeaveRequestViewController.m:103:0
/Users/dk/Desktop/xxx/Classes/DetailedLeaveRequestViewController.m:103: error: expected expression before 'UITextView'
в строке
UITextView *commentsView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
в случае 4:
Я дважды проверял синтаксис и все остальное снова и снова, но мог проблем не обнаружил. Странная часть - это когда я пытался скомпилировать строку под последней строкой case 3: (сразу над разрывом;) она скомпилировалась и работала правильно. Можем ли мы не объявить и инициализировать объект внутри оператора case? Мне здесь не хватает чего-то довольно простого?
Спасибо.