我正在将一些代码从一个项目复制到另一个项目以填写表格View, 我收到此错误
ABC Forbids explicit message sent of auto release
当我尝试创建UITableViewCell对象时。
- (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];
}
答案 0 :(得分:0)
我认为你的意思是ARC(不是ABC)?当您的项目使用自动引用计数时,您无需致电release
,retain
或autorelease
。在这种情况下,你可以摆脱autorelease调用,你的代码应该编译。
答案 1 :(得分:-1)
如果你不使用ARC(或ABC:D),你应release
正常-(void)delloc
如果你使用删除代码行(只是autorelease
)。