是否可以在不将每个 .m 文件更改为 .mm 的情况下执行此操作?
好的。我正在尝试实施答案,但遇到了麻烦。看看下面我的 Objective C++ .h 和 .mm
Objective-C++ - IDCaptureTemplateCommand.h:
#include "Template.h"
@interface IDCaptureTemplateCommand : NSObject
@property (nonatomic, strong) IDCaptureTemplateCommand *IDCaptureTemplateCommand;
@end
Objective-C++ - IDCaptureTemplateCommand.mm:
#include "IDCaptureTemplateCommand.h"
@implementation IDCaptureTemplateCommand
- (id)init
{
self = [super init];
if (self) {
self.captureTemplateCommand = [[IDCaptureTemplateCommand alloc] init];
}
return self;
}
@end
Objective-C - IDCameraViewController.h
#import <UIKit/UIKit.h>
#import "IDCaptureTemplateCommand.h"
@interface IDCameraViewController : UIViewController <UINavigationControllerDelegate>
@property (nonatomic) IDCaptureTemplateCommand *captureCommand; //ERROR - Unknown type name 'IDCaptureTemplateCommand'
@end