2012-10-03 23 views
-2

我複製從一個項目的一些代碼到另一個填寫表格視圖, 我得到這個錯誤iPhone越來越ABC發送,禁止使用自動釋放的

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

HAHA。你的意思是ARC? – Legolas

回答

0

我想你的意思是ARC(不是ABC)?當您的項目使用自動引用計數時,您不打算撥打release,retainautorelease。在這種情況下,你可以擺脫autorelease調用,你的代碼應該編譯。

-1

如果你不使用ARC(或ABC:d)U應該只是release它通常在-(void)delloc 如果你使用delete的代碼行(只是autorelease)。

+0

在非ARC代碼中,此方法仍然需要發佈! –