Objective-C: Importing headers in .h or .m?

后端 未结 4 1384
我在风中等你
我在风中等你 2021-02-02 09:15

I\'m new to objective-c and would like to know the best practice for importing some external headers that I use in my class.

Should I be storing the #import \"classB.h\"

4条回答
  •  余生分开走
    2021-02-02 09:55

    It is proper practice to put a forward class declaration (@class classB;) in the header and #import "classB.h in the .m

    A forward class declaration, like @class classB; lets the compiler know it should expect the class later on, and it shouldn't complain about it at the moment.

提交回复
热议问题