gpt4 book ai didi

objective-c - autorelease 在自动引用计数模式下不可用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:29 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Im getting this error ‘autorelease’ is unavailable: not available in automatic reference counting mode

我正在通过一本名为 Objective-C fundamentals 的书学习 Objective-C,该书于 2011 年出版。它正在构建一个简单的应用程序来介绍 iOS 概念并教授 Objective-C 语言。自本书出版以来,平台或语言似乎发生了一些变化。当我尝试从书中构建代码时(下面摘录了关键段落),我遇到了这个错误:

autorelease is unavailable: not available in automatic reference counting mode
ARC forbids explicit message send of 'autorelease'

错误消息出现在代码中实际使用 autorelease 的几行上方。

我只有大约 1 小时的 Objective-C 和 iOS 经验,所以我不知道如何解决这个问题以便继续阅读本书。任何帮助,将不胜感激。

- (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;
}

如果我不能解决这些类型的小问题,那么我将无法继续阅读本书。如果我可以使用某种版本系统(比如 Ruby 的 rvm)来避免此类问题,请告诉我。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com