Re: NSArrayController selection bug?
Re: NSArrayController selection bug?
- Subject: Re: NSArrayController selection bug?
- From: Henrik Wittland <email@hidden>
- Date: Wed, 12 Nov 2003 00:09:05 +0100
Am 11.11.2003 um 21:54 schrieb Jesse Grosjean:
Thanks for all of your feedback.
But it breaks the separation between MODEL and VIEW in the MVC
paradigma.
No, it does not. Both objects are controllers (recall Jesse's
original method:
- (IBAction)modelRemove:(id)sender {
[...]
)
Actually the example that I posted was just a quick demo to show the
bug. In my actual code these methods are all in my model objects and I
don't have easy access to the NSArrayController.
As expected with a model which separates between Model,View and
Controller.
But unfortunately I also don't really have a backing NSMutableArray
behind the scenes that I can change to get around the bug by creating
a new array. Instead the to-many mutable KVC methods are accessing a
separate database layer, not a backing NSMutableArray.
Which database layer are you using?
I suppose that I could create an extra layer following the
NSMutableArray protocol, but that's not a very appealing solution to
me. If anyone has ideas on how to get around the issue please send
them this way.
@implementation YourModelClass_or_YourModelRootClass
(NSArrayControllerSelectionFixForBehindTheScenesObjectRemoval)
-(id)valueForKey:(NSString *)key {
id value = [super valueForKey:key];
if ([value isKindOfClass:[NSArray class]]) {
return [NSArray arrayWithArray:(NSArray *)value];
} else {
return value;
}
}
@end
You can easily remove this category after the problem gets fixed. Apple
teaches us to not overwrite valueForKey: but this is a workaround.
Has anyone out there started work in a generic
NSOutlineViewController? I understand that it couldn't be used to bind
the the NSOutlineView in interface building, but it would making
writing the NSOutlineViews datasource and delegate much easier I
think. I think I may just try to follow NSArrayControllers basic
design, but fix it so that it works with my code (and probably
introduce many other bugs in the process) and also make it work with
outline views.
It appears that there is indeed a bug here -- if you haven't already,
Jesse would you please report it?
Yeah I'll send this one in.
Thanks for everyone's help.
Jesse
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.