すべての.mファイルを.mmに変更せずにこれを行うと言っていますか?
OK。私は答えを実装しようとしているが、問題がある。私の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
回答:
回答№1の場合は3あなたはCや他のものからC ++を使うのと同じようにすることができます。純粋なObjective-Cを使用してインタフェースを宣言できる必要があり、Objective-C ++を使用して実装を記述することができます。
ヘッダファイルがC ++を使用している場合(例:あなたのクラスには std::string
インスタンス変数を設定し、次に機能を作成しますObjective-Cからアクセスできるようにするには、ラッパーを記述するか、インタフェースでC ++を非表示にする必要があります。そのため、Objective-CファイルはC ++宣言のいずれかを参照する必要はありません。