我有一个迅速而客观的c ++项目。如果我在Objective c ++(。mm)文件中使用Appdelegate,则会收到类似以下错误:
/Projects/Controllers/BalanceCheck/BalanceCheckVC.mm:17:19: error: expected expression
(AppDelegate *)[[UIApplication sharedApplication] delegate]
^
在头文件OpenCVWrapper.h中:
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface OpenCVWrapper : NSObject
+ (NSString *)openCVVersionString;
@end
NS_ASSUME_NONNULL_END
在OpenCVWrapper.mm文件中
#import "OpenCVWrapper.h"
#import <opencv2/opencv.hpp>
@implementation OpenCVWrapper
+ (NSString *)openCVVersionString {
//ERROR
AppDelegate* testAppdel = (AppDelegate *)[[UIApplication sharedApplication] delegate];
return [NSString stringWithFormat:@"OpenCV Version %s", CV_VERSION];
}
@end
我已经做了什么: 桥接头已包含在内