如何使用Objective c ++修复Swift项目中未声明的标识符'AppDelegate'的使用

时间:2019-04-04 05:45:43

标签: objective-c swift objective-c++

我有一个迅速而客观的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

我已经做了什么: 桥接头已包含在内

0 个答案:

没有答案