Possible Duplicate:
Im getting this error ‘autorelease’ is unavailable: not available in automatic reference counting mode
I'm learning Objective-C with a book called Objective-C fundamentals, published 2011. It's building a simple app to introduce iOS concepts and teach the Objective-C language. Seems like there's been some changes to the platform or language since publication of the book. When I try to build code from the book (key passage excerpted below), I'm getting this error:
autorelease is unavailable: not available in automatic reference counting mode
ARC forbids explicit message send of 'autorelease'
The error message appears a few lines above where autorelease is actually used in the code.
I only have about 1 hour's worth of experience with Objective-C and iOS, so I have no idea how to fix this so I can continue along with the book. Any help would be appreciated.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){ #### error message here
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier]autorelease]; ### autorelease used here
}
cell.textLabel.text = [NSString
stringWithFormat:@"Rental Property %d", indexPath.row];
NSLog(@"Rental Property %d", indexPath.row);
return cell;
}
If I can't fix these types of small problems, then I won't be able to follow along with the book. If there's some sort of version system I could use (like rvm for Ruby) to avoid this type of problem, please let me know.