XCode thinks that an NSMutableArray is an NSArray

Discussion in 'Mac Programming' started by BadWolf13, May 25, 2014.

  1. BadWolf13 macrumors 6502

    Joined:
    Dec 17, 2009
    #1
    Hi everyone, I've got a doozy here that I can't figure out, and can't find a solution anywhere to.

    I've declared an NSMutableArray within my app delegate class, and in that class, I can add and remove objects to my heart's content. However, when I access the mutable array from another class, XCode seems to think it's an immutable array. I enter this code:

    Code:
    [[[NSApp delegate] windowControllers] addObject:newWindowController];
    
    And I get the error:

    Even stranger, when I typed that line of code, the autocomplete window showed windowControllers as an NSArray. Just to show that it's declared and initialized properly, here's the code for the declaration and initialization of the mutable array:

    Code:
        NSMutableArray *windowControllers;
    
    Code:
    @property (strong) NSMutableArray *windowControllers;
    
    Code:
        windowControllers = [[NSMutableArray alloc] init];
    
    Anyone got any ideas?
     
  2. bennibeef macrumors 6502

    Joined:
    May 22, 2013
    #2
    Try a different name. A property windowsControllers is already there, the standard windowcontroller array, which is in fact a NSArray
     
  3. BadWolf13 thread starter macrumors 6502

    Joined:
    Dec 17, 2009

Share This Page