Dynamic NSArrayContent changing [was: NSTableColumn value binding]
Dynamic NSArrayContent changing [was: NSTableColumn value binding]
- Subject: Dynamic NSArrayContent changing [was: NSTableColumn value binding]
- From: Stamenkovic Florijan <email@hidden>
- Date: Wed, 30 Sep 2009 11:57:45 -0400
On Sep 30, 2009, at 10:36, Bryan Matteson wrote:
May also want to look at this.
http://www.mail-archive.com/email@hidden/msg31802.html
It seems to be very possible that it may be a bug, but it's also a
common coding mistake as well.
Hope it works itself out.
Bryan,
I looked into it. The problem described relates to
"willChangeValueForKey" not being called, thus violating KVO. This is
not the problem I have.
Further investigation seems to suggest that it is an action of mine
that triggers this. And not even the workaround that I have been using
fixes it. Actually, completely removing the table column in question
does not fix it. The problem is elsewhere, but I have a lead...
I dynamically change the content set / array of my array controller as
a user preference changes. The situation is that there is a user
preference for "see all notes". If it's value is YES, then I bind my
array controller's array content to another array controller that
simply fetches all Notes. if it is NO, then I bind my array
controller's set to NSTreeController.selection.items (where selection
is a Group, and items the Notes it relates to)... It seems that this
change is causing this to happen...
Here is some extra weirdness... The error is exhibited only when I
shift back to not viewing all notes. So, when I first start up the
app, I can drag and drop no problem, regardless if viewing all notes
or the notes from the selected group. If I shift from seeing group
notes to seeing all, also no problem. Only when shifting from seeing
all to seeing selected group notes do I get this problem.
Perhaps I am not allowed to this, or need to do it differently? Here
is the code for the change... I will experiment with it... It is a
setter for a property bound to
NSUserDefaultsController.values.viewingAllNotesPref
-(void)setViewingAllNotes:(NSNumber*)newValue
{
// assign the new value
id oldValue = viewingAllNotes;
viewingAllNotes = [newValue copy];
[oldValue release];
// react appropriately
if([viewingAllNotes boolValue]){
// cache and then remove the current selection of the groups
controller
lastSelectedGroupsIndexPaths = [[groupsController
selectionIndexPaths] retain];
[groupsController setSelectionIndexPaths:nil];
// re-direct the bindings of the notesController
[notesController unbind:@"contentSet"];
[notesController bind:@"contentArray"
toObject:allNotesController
withKeyPath:@"arrangedObjects"
options:nil];
}else{
// restore and then release the last selection of the groups
controller
[groupsController
setSelectionIndexPaths:lastSelectedGroupsIndexPaths];
[lastSelectedGroupsIndexPaths release];
lastSelectedGroupsIndexPaths = nil;
// re-direct the bindings of the notesController
[notesController unbind:@"contentArray"];
[notesController bind:@"contentSet"
toObject:groupsController
withKeyPath:@"selection.items"
options:[NSDictionary dictionaryWithObject:[NSNumber
numberWithBool:YES]
forKey:NSDeletesObjectsOnRemoveBindingsOption]];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden