@class May I know the proper use of this

前端 未结 3 809
余生分开走
余生分开走 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:21

    // header.h
    #import 
    @class reference;
    
    @interface class
    ...
    @end
    // implementation.m
    #import "header.h"
    #import "reference.h"
    
    @implementation class
    ...
    @end
    

    you use this when you have a class that is referenced circularly between multiple files, and you import the header that contains the class described by the @class directive, and you can safely refer to the class circularly.

提交回复
热议问题