@class vs. #import

后端 未结 16 1318
渐次进展
渐次进展 2020-11-21 22:42

It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header t

16条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 23:34

    if we do this

    @interface Class_B : Class_A
    

    mean we are inheriting the Class_A into Class_B, in Class_B we can access all the variables of class_A.

    if we are doing this

    #import ....
    @class Class_A
    @interface Class_B
    

    here we saying that we are using the Class_A in our program, but if we want to use the Class_A variables in Class_B we have to #import Class_A in .m file(make a object and use it's function and variables).

提交回复
热议问题