Access NSMutableArray from a different class

前端 未结 3 1226
自闭症患者
自闭症患者 2021-01-25 22:55

I have a class where a NSMutableArray object is formed, as so:

navBarColour = [[NSMutableArray alloc] initWithObjects:colourOfNavBar, nil];

I t

3条回答
  •  生来不讨喜
    2021-01-25 23:37

    The dot notation is used differently in objective c that from c++ or java. In objective-c it is shorthand for accessing a property. You need to have defined a objective-c property first, like this:

    in the .h file (INSIDE the interface tag)

    @property (nonatomic, retain) NSMutableArray *navBarColor;
    

    in the .m file (INSIDE the implementation tag)

    @synthesize navBarColor;
    

    Only then can you access the array with the dot notation.

提交回复
热议问题