Objective-C ++ C ++ Object Destructor

I have an Objective-C class, one of which is a C ++ object (most of my code is C ++, but I need some ObjC classes to integrate with iOS libraries). Does Objective-C ++ guarantee that a C ++ object will be correctly destroyed when an Objective-C object is destroyed?

Code example:

class MyCppClass { // ... }; @interface MyObjCClass : NSObject { MyCppClass myCppObject; // is it ok to do it? } // ... @end 
+4
source share
1 answer

Yes. After calling the -dealloc method, the hidden .cxx_destruct method is .cxx_destruct . This method calls all destructors of all instance variables that have a destructor.

+3
source

All Articles