subclass of NSArrayController

Discussion in 'Mac Programming' started by MrFusion, Feb 28, 2008.

  1. macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #1
    Hello,

    I have a question about good coding practices.

    I have a NSTreeController binded to a NSManagedObjectContext, which works fine.
    The NSArrayController is binded to the selection of NSTreecontroller. For single selections, everything works fine. But when the selection is zero or multiple the NSArrayController has to return different values, also depending on what is selected.

    The problem is that my subclass of NSArrayController complete ignores my code, and goes straight the the NSManagedObjectContext and gives the standard reply of Empty Selection and Multiple Values.
     
  2. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #2
    Don't have time to check if my recommendation is right, and I may be total wrong about this... But have you tried creating a category, and not a subclass of the NSTreeController? Maybe you can override functions through this.
     
  3. thread starter macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #3
    Category? No, never done anything like this.
    Is that similar as adding a protocol to a subclass?
     
  4. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #4
    Actually, a protocol lets you add methods into an existing class without altering it. You can do it to improve functionality of existing Cocoa classes. I recommend you consult your book on how to do that, or to read Apple's quick ObjC guide about protocols.

    However, I don't know if you can override functions of a class using a protocol. But it's worth giving a shot.
     

Share This Page