in Objective-C, how to access private property from category

后端 未结 1 969
孤城傲影
孤城傲影 2021-02-07 10:39

I want to access private property of a class from its category.

But to access private property, I have to redeclare the same private property in category.
If I don\'

相关标签:
1条回答
  • 2021-02-07 11:20

    The best way to solve this is to create ClassA+Private.h and import it in ClassA.m and Category.m. Mind the h at the end, you only need to declare your private properties and methods there, the definition is better kept in ClassA.m.

    0 讨论(0)
提交回复
热议问题