-2

I'm copying some code from one project to another to fill in a table View, I'm getting this error

ABC Forbids explicit message sent of auto release

when I'm trying to create a UITableViewCell object.

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
       // this line produces the error
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
Ted pottel
  • 6,869
  • 21
  • 75
  • 134

2 Answers2

0

I think you meant ARC (not ABC)? When your project is using Automatic Reference Counting, you're not meant to call release, retain, or autorelease. In this case you can just get rid of the autorelease call and your code should compile.

wulong
  • 2,657
  • 1
  • 20
  • 19
-1

If you are not using ARC (or ABC :D) u should just release it normally in the -(void)delloc And if you using delete the line of code (just the autorelease).

Noah
  • 67
  • 8