Pure C function calling Objective-C method?

后端 未结 3 1064
囚心锁ツ
囚心锁ツ 2020-12-31 23:27

Okay, I\'ve read half a dozen threads on this subject, but none of the solutions appear to address exact needs.

Question:

How does a Pure C (.c) fun

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 00:15

    Objective C can compile c method without any modification. To call c method from objective-c class you have to whatever you do in c, just include the header file then call method directly. Suppose you have a C header named test.h and in that you have a method sum(int i, int j); then first include test.h and then call test(1, 2);

    If you want to call C++ method, use Objective-C++ (.mm extension) in the same manner as explained above.

提交回复
热议问题