I've already looked at the other SO discussions but can't seem to find an answer. I'm getting this answer after basically the following code:
1) In the class that owns the AwesomeMenu, I am making an NSMutableArray of AwesomeMenuItems, which is required to initialize the AwesomeMenu:
NSMutableArray *menus = [[[NSMutableArray alloc] init] autorelease];
[menus addObject:starMenuItem1];
[menus addObject:starMenuItem2];
[menus addObject:starMenuItem3];
[menus addObject:starMenuItem4];
[menus addObject:starMenuItem5];
AwesomeMenu *menu = [[[AwesomeMenu alloc] initWithFrame:self.view.bounds menus:menus view:self.view] autorelease];
2) In AwesomeMenu.h, I have the array declared in the interface like so:
NSMutableArray *_menusArray;
And I've made a property for the array:
@property (nonatomic, retain) NSMutableArray *menusArray;
and it is synthesized:
@synthesize menusArray = _menusArray;
3) In the initWithFrame: menus: view: , I assign the menus parameter like so:
- (id)initWithFrame:(CGRect)frame menus:(NSMutableArray *)aMenusArray view:(UIView*)gView
{
self = [super initWithFrame:frame];
// ... some code
self.menusArray = aMenusArray; // BREAKPOINT HERE.
// ... some more code
}
4) I put a breakpoint at the assignment and here is what happens. Immediately before that line is run, I check my self.menusArray and it is: (NSMutableArray *)0x00000000 0 Objects
I step over the line and it becomes: (__NSArrayI *) 0x06045070 5 objects.
While this is the correct number of objects, it is no longer a NSMutableArray which runs me into problems later!
What is happening and how can I stop it from happening?