Why does a subclass @property with no corresponding ivar hide superclass ivars?

后端 未结 2 1389
-上瘾入骨i
-上瘾入骨i 2020-12-06 10:57

The following seems simple enough. There\'s a superclass with an ivar, and a subclass which accesses the (@protected) superclasses ivar:

// Testclass.h    
@         


        
相关标签:
2条回答
  • 2020-12-06 11:39

    LLVM compiles the source without complaints, switch to LLVM: Select target → Get Info → Build → C/C++ Compiler Version → LLVM 1.5. From my limited experience it’s a better compiler anyway. No idea why GCC behaves the way it does – interesting catch.

    0 讨论(0)
  • 2020-12-06 11:53

    The testIvar undeclared error is actually red herring in this case. This message seems to be caused by testProperty not having a corresponding ivar. To resolve the issue either declare a testProperty ivar in TestSubClass.h or make testProperty @dynamic in TestSubClass.m.

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