Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling callback function from c++ to objective c
    text
    copied!<ol> <li>I am using c++ library in my objective c project.</li> <li>I integrated c++ library and implemented .mm file to bridge c++ and objective c.</li> <li><p>I can successfully call c++ function from my objective c using this .mm bridge.</p></li> <li><p>The issue is that methods in given c++ library return's nothing i.e Void. For example void login( const char* email, const char* password);</p></li> <li><p>This c++ library have call back function implemented to know the result of this login method.</p></li> </ol> <p>Example: </p> <pre><code>class DemoApp : public XClass { int urandomfd; public: uint32_t dstime(void); FileAccess* newfile(); void request_error(MegaClient*, error); void login_result(MegaClient*, error); void users_updated(MegaClient*, User**, int); void nodes_updated(MegaClient*, Node**, int); int prepare_download(MegaClient*, Node*); void share_result(MegaClient*, int, error); void account_details(MegaClient*, AccountDetails*, int, int, int, int, int, int); void topen_result(MegaClient*, int, error); void topen_result(MegaClient*, int, string*, const char*, int); void transfer_update(MegaClient*, int, off_t, off_t, uint32_t); void transfer_error(MegaClient*, int, int, int); void transfer_failed(MegaClient*, int, error); void transfer_failed(MegaClient*, int, string&amp;, error); void transfer_limit(MegaClient*, int); void transfer_complete(MegaClient*, int, chunkmac_map*, const char*); void transfer_complete(MegaClient*, int, const byte*, const byte*, SymmCipher*); void changepw_result(MegaClient*, error); void reload(MegaClient*, const char*); void notify_retry(MegaClient*, int); void debug_log(MegaClient*, const char*); DemoApp(); }; </code></pre> <ol> <li><p>So now my concern is how and when should i call these CALLBACK function's in my objective C library, which look's to me that they are called internally in c++ library.</p></li> <li><p>This is my wrapper.mm file, wrapping c++ methods, need to call in objective c.</p> <p>-(void) WrapLogin:(NSString*) email :(NSString*) pwd{</p> <p>self.wrappedModelAccessMega->Login([email UTF8String], [pwd UTF8String]); //No return as Login mfunction from c++ library returns nothing i.e void</p> <p>}</p></li> <li><p>I am working on it from a while and already pushed hard to integrate this library to my objective C library now i got stuck to it due to these callback function's. Please small example showing how should i use callback function of c++, wrap it and call in my objective c to get/know result/return of my login function will do the great job for me.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload