Access to cpp variable from objective c .mm file in qt
I've used a .mm file in my qt creator to implement an ios application. I've declared a cpp method in header file and i've implemented it on .mm file.then in cpp file implementation, i've called an objective-c method for fetching addressbook.
@interface MyObject :NSObject
-(int)doSomethingWith:(void *) aParam;
int MainWindow::MyCPPMethod(void *self, void * aParam)
self = [[MyObject alloc] init];
return [(id) self doSomethingWith:aParam];
-(int)doSomethingWith:(void *) aParam
NSLog(@“Result: %d” , 21);
Everything is right, but i want to use some objective-c variable in cpp side (mainwindow class). how can i share a variable between cpp class and objective-c class in qt?
[edit: added missing coding tags @ SGaist]
Have a look at the QtMacExtras module. It implements that technique
Thanks for your help, but i want something like this:
- fetch contacts names from ios addressbook( with objective-c code in .mm file)
- save each contact name in an array like QString name ( the array is defined in a cpp class)
how can do that?
If i define the array in cpp header file, it is not recognized in .mm file.
Don't create an array of QString, just a QStringList, it will make your life easier. Also don't try to share variables like that especially if you are just trying to access some data.
Follow the code of badgeLabelText in qmacfunctions.h/qmacfunctions_mac.mm