【问题标题】:'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode [duplicate]'NSAutoreleasePool'不可用:在自动引用计数模式下不可用[重复]
【发布时间】:2018-11-07 22:24:06
【问题描述】:

我在 xcode 中使用此代码并显示错误“'NSAutoreleasePool' 不可用:在自动引用计数模式下不可用”。在最新的 xcode 版本中编写此代码的正确方法是什么。

  {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        NSLog(@"Base class Person Object");
        Person *person = [[Person alloc]initWithName:@"Raj" andAge:5];
        [person print];
        NSLog(@"Inherited Class Employee Object");
        Employee *employee = [[Employee alloc]initWithName:@"Raj" andAge:5 andEducation:@"MBA"];
        [employee print];
        [pool drain];
    }

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    您正在使用 ARC 模式 ON 代码(启用自动参考),首先您必须通过 Xcode 的设置禁用它,请参阅下面的讨论:

    How to enable/disable ARC in an xcode project?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 2014-09-12
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多