search

Home  >  Q&A  >  body text

开启了ARC的objective-C++代码中C++对象是否需要手动释放?

开启了ARC的objective-C++代码中C++对象是否需要手动释放?

PHPzPHPz2808 days ago563

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 11:47:05

    Required. ARC is just a compiler technology that automatically inserts retain/release by scanning the code. C++ code is not within the scope of recognition by the compiler, and the life cycle can only be managed by itself.

    In addition, ARC technology is a "backward" technology that has to be used because the Obj-C language itself cannot implement automatic reference counting. For C++, you can directly use the smart pointer classes provided by the standard library such as shared_ptr/unique_ptr/weak_ptr. Able to write code as clean as ARC. In a sense, using smart pointers, C++ objects do not need to be released manually.

    reply
    0
  • Cancelreply