Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrFusion

macrumors 6502a
Original poster
Jun 8, 2005
613
0
West-Europe
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.
 
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.

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.
 
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.

Category? No, never done anything like this.
Is that similar as adding a protocol to a subclass?
 
Category? No, never done anything like this.
Is that similar as adding a protocol to a subclass?

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.