' NSAutoreleasePool'不可用:在自动参考计数模式下不可用

时间:2018-05-29 09:53:35

标签: ios objective-c

我在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];
    }

1 个答案:

答案 0 :(得分:0)

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

How to enable/disable ARC in an xcode project?