What does @class do in Objective-C?

前端 未结 4 2015
清酒与你
清酒与你 2020-12-12 16:06

Can anyone please explain me what does @class declaration do in Objective-C and what are the cases in which we should use this declaration?

4条回答
  •  隐瞒了意图╮
    2020-12-12 16:59

    it is called a forward declaration.

    you use this directive to tell the compiler that there is an objc class with the name specified. your other options are to include the interface, or use id for variables or types.

    this is helpful to minimize dependencies. i use them whenever i can to minimize dependencies, and significantly reduce build times.

    it's the same as in c and c++:

    struct mon_struct;
    namespace MON { class mon_class; }
    

提交回复
热议问题