如何在Objective-C中调用C文件中的一个方法?
3个回答
推荐于2016-10-07
展开全部
As Objective-C is a superset of C, it allows developers to mix pure c source files with Object-C source files.But to call a C function from Objective-C, you should not import the .c file in your Objective-C .m file, that won’t work.To call a C function from the Objective-C, you need to create a .h header file to include the C function declaration, and, of cause, include the .h file in the .c source file where the C function resides. Then import the .h file in the .m source file where you would like to call the C function, and simply call the function.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-30
展开全部
嗯,那就用.m吧。一般cpp文件中定义c函数要加上extern "C",类似这样#ifndef MODULE_A_H #define MODULE_A_H extern "C" int foo( int x, int y ); #endif
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-30
展开全部
就是引入头文件,按照正常c语言调用啊objective-c是兼容c的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询