Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I mix C++ code in Objective C who manages memory for C++ object would ARC handle it?

If I create/allocate C++ objects in objective C such that Objective C objects are using pointers of the C++ objects and the code is intermingled will ARC manage C++ objects too and release/free them ?? What happens to C++ object whose pointer is in a Objetive C object which is not accessible ? and proposed candidate for removal from memory ??

like image 391
Ahmed Avatar asked Jan 24 '13 01:01

Ahmed


1 Answers

According to Cocoa Core Competencies: Object life cycle, you should free resources in the dealloc method. For a "raw" C++ pointer, this means writing a delete expression.

ARC's part is to insert retain and release calls such that dealloc happens once an object is no longer accessible.

like image 90
Potatoswatter Avatar answered Oct 06 '22 23:10

Potatoswatter