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];
}
I think you meant ARC (not ABC)? When your project is using Automatic Reference Counting, you’re not meant to call
release,retain, orautorelease. In this case you can just get rid of the autorelease call and your code should compile.