在iOS5中,在故事板采用ARC和原型细胞的tableView,我可以代替下面的代码:dequeueReusableCellWithIdentifier是否适用于ARC?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell...
return cell;
有了这个简单的代码?:
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
我看到了这此链接:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
提前致谢!
是的,你可以。另外,它不需要ARC。只要您使用iOS 5和故事板,就可以使用新模式。 – 2012-02-04 17:31:02
@JasonCoco:这应该是一个答案,而不是评论。 – 2012-02-04 17:33:04
@JasonCoco我不明白为什么,但这件事对我来说不起作用。我不断收到一个“无”单元格。我创建了一个新的主 - 细节项目。这个例子很好用。当我添加cellForRowIndexPath方法和表大小方法并将大小设置为2时,我得到一个异常,因为dequeueReusableCellWithIdentifier一直让我“无”。 – ericyue 2012-02-04 17:43:20