如何在ObjectiveC项目C ++文件中使用

时间:2023-01-17 13:11:24

I have a reqular objective C project. I import 10 C++ files into my project. All this files take "are communicating" with each other. If I have a look at File1.h, this file can manage all the operations in other class.

我有一个reqular Objective C项目。我将10个C ++文件导入到我的项目中。所有这些文件都“相互通信”。如果我查看File1.h,该文件可以管理其他类中的所有操作。

So, the question is How to include reference to File1.h and to call functions from it. For example: [File1Class getAudioData]; If I include it by #include "File1.h", I will get a error "Class is unknown element"

所以,问题是如何包含对File1.h的引用并从中调用函数。例如:[File1Class getAudioData];如果我通过#include“File1.h”包含它,我将收到错误“Class is unknown element”

P.S. I want to import aurioTouch2 sample code to my project and to call functions from theire C++ code.

附:我想将aurioTouch2示例代码导入到我的项目中,并从C ++代码中调用函数。

1 个解决方案

#1


1  

You Can simply open both the projects in Xcode and drag and drop the files you need from the aurioTouch2 application. Make sure the files are actually copied by selecting the check mark that you get after you drop the files in your xcode project. After this, you will be able to use those files/classes. Consider using ".mm" as the extension of the implementation file in which you want to use the c++ files/classes. You may also use ".mm" as extension for your appdelegate implementation file in case you get c++ related errors.

您只需在Xcode中打开两个项目,然后从aurioTouch2应用程序中拖放所需的文件即可。通过选择在xcode项目中删除文件后获得的复选标记,确保实际复制文件。在此之后,您将能够使用这些文件/类。考虑使用“.mm”作为要在其中使用c ++文件/类的实现文件的扩展名。如果出现与c ++相关的错误,您也可以使用“.mm”作为appdelegate实现文件的扩展名。

#1


1  

You Can simply open both the projects in Xcode and drag and drop the files you need from the aurioTouch2 application. Make sure the files are actually copied by selecting the check mark that you get after you drop the files in your xcode project. After this, you will be able to use those files/classes. Consider using ".mm" as the extension of the implementation file in which you want to use the c++ files/classes. You may also use ".mm" as extension for your appdelegate implementation file in case you get c++ related errors.

您只需在Xcode中打开两个项目,然后从aurioTouch2应用程序中拖放所需的文件即可。通过选择在xcode项目中删除文件后获得的复选标记,确保实际复制文件。在此之后,您将能够使用这些文件/类。考虑使用“.mm”作为要在其中使用c ++文件/类的实现文件的扩展名。如果出现与c ++相关的错误,您也可以使用“.mm”作为appdelegate实现文件的扩展名。