简体   繁体   中英

How to retrieve Objective-C variable from C++ method?

I mixed some C++ codes with Objective-C in class with .mm extension.

I synthesized some variables in Objective-C, and I want to retrieve those variables in C++ methods. How to do that?

I tried [self aVariable], this->aVariable to retrieve the synthesized variables, but failed.

You cannot use self in a C++ class. this->aVariable doesn't say anything. It doesn't say whether you are trying to call a method. In fact it doesn't do anything with aVariable.

I assume the method is attached to an objective-C object. If so call it as follows from the C++ class:

[aVariable <method>];

I fixed my problem after reading this post:

Calling Objective-C method from C++ method?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM