我正在研究一个只需要重写的项目,但这不是一个选项。从C++函数访问Objective-C变量
我有一个C++函数被调用,并做各种东西。我需要它从App Delegate类读取一个变量。
比如我有:
@interface MyAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
MyViewController *viewController;
int mToleranceLevel;
}
然后我有一个需要访问mToleranceLevel功能:
bool FindExtrinsics(...)
{
float maxError = mainDelegate.mMaxError;
...
}
的问题是,这个被宣布像这样:
@interface MyClass : UIViewController
{
...
}
@properties ...
bool FindExtrinsics(...);
@end
那么我怎么会从AppDelegate类中获得一个值。我知道如何获得当前代表:
mainDelegate = (RedStripeARAppDelegate *)[[UIApplication sharedApplication] delegate];
但是,如何使用此信息来获取我的C++函数中的值。有没有办法让一个静态变量,所以我可以调用MyAppDelegate.mToleranceValue; ??
的AppDelegate * AD =((AppDelegate中*)CCApplication :: sharedApplication()); – 2014-07-09 07:46:51