How to create global functions in Objective-C

前端 未结 5 1654
攒了一身酷
攒了一身酷 2020-11-30 02:03

I\'m developing an iphone app and I need to have some functions to use globally in my classes.

But how can I do this?

I just tried to create functions.

5条回答
  •  悲&欢浪女
    2020-11-30 02:34

    What your error is referring to is you need to have that method in an interface.

    @interface SomeClass
    - (void)printTest;
    @end
    

    To use a static void throughout your app (where you have included your Functions.h), try the following:

    void printTest ()
    {
        /* do your print stuff */
    }
    

提交回复
热议问题