Why are instance variables defined in the header file in Objective-C

前端 未结 6 1492
一个人的身影
一个人的身影 2021-01-12 22:36

I can understand defining the functions in the @interface of the header file, but why the instance variables? Shouldn\'t the instance variables be private, only accessible

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 22:57

    I think it is a technical issue. If I understand correctly, a Objective-C class is just a fancy C struct. And for a struct to be used its size must be known. (Like how would sizeof() work otherwise)

提交回复
热议问题