@class May I know the proper use of this

前端 未结 3 835
余生分开走
余生分开走 2021-01-07 11:34

Anyone can point out a documentation or a detailed discussion using @class. I\'ve been using this but haven\'t really fully understood it. I want to learn more about it and

3条回答
  •  遥遥无期
    2021-01-07 12:02

    @class is used to declare a class. Essentially telling the compiler: "Hey, there is a class with this name somewhere in the source code. The definition will come later, but let me use its name as a pointer type for now."

    See also:
    developer.apple.com
    SO: Class vs Import
    MacRumors

    Note: As pointed out by Richard J. Ross III, the @class keyword allows for circular references (when two classes both depend on each-other) without breaking the build.

提交回复
热议问题