CabForward/iOS-on-Rails — Issue #7: Autorelease missing?
Author: perfectionist
Created: 2011-12-14 19:33:17+00:00
State: open

The `table:cellForRowAtIndexPath:` method in `EmployeeListViewController.m` seems to be missing an `autorelease`.

```objective-c

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

Employee *employee = [self.employees objectAtIndex:indexPath.row];

cell.textLabel.text = employee.name;
cell.detailTextLabel.text = employee.jobTitle;

return cell;
}
```

I think it should be:

```objective-c

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

Employee *employee = [self.employees objectAtIndex:indexPath.row];

cell.textLabel.text = employee.name;
cell.detailTextLabel.text = employee.jobTitle;

return cell;
}
```
(see page 186 in Conway and Hillegass).