I defined two classes: Player and HelloWorldLayer. In HelloWorldLayer, I defined a member variable: NSArray *bullets. In Player, I defined a member variable HelloWorldLayer *hwLayer. Now in one of Player‘s function, I want to visit bullets with hwLayer.bullets, but it doesn’t work and gives a compile error. I’ve attached screen shots – can anyone help me determine what’s wrong?





You forward-declare
HelloWorldLayerin the headerIt lets you declare _hwlayer instance variable. However, it is not sufficient to start using its properties: but you must import the header that contains
HelloWorldLayerinto the .m file that referencesbullets.Alternatively, you can use the square bracket syntax, like this:
This does not require importing the header.