重複の可能性:
このエラーが発生します 'autorelease' is available: not available in automatic reference count mode
私は、2011 年に発行された Objective-C の基礎と呼ばれる本で Objective-C を学んでいます。この本は、iOS の概念を紹介し、Objective-C 言語を教えるシンプルなアプリを構築しています。本の出版以来、プラットフォームまたは言語にいくつかの変更があったようです. この本からコードを作成しようとすると (以下に抜粋された重要な箇所)、次のエラーが発生します。
autorelease is unavailable: not available in automatic reference counting mode
ARC forbids explicit message send of 'autorelease'
エラー メッセージは、コード内で autorelease が実際に使用されている数行上に表示されます。
私は Objective-C と iOS で約 1 時間の経験しかないので、これを修正する方法がわからないので、本を読み進めることができます。どんな助けでも大歓迎です。
- (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 など) がある場合は、お知らせください。