Problem with unbind:
Problem with unbind:
- Subject: Problem with unbind:
- From: Martin Hewitson <email@hidden>
- Date: Sun, 23 Aug 2009 11:30:11 +0200
Dear list,
I've been trying to do some programmatic bindings because I want to
change a binding depending on the state of a check box. In more
detail, I have an NSArrayController whose contents I want to bind to
either all entities of a particular type in the MOC, or to a subset of
those. This is a 'show all' check box.
So far I have tried the following code:
- (IBAction)showAllEntries:(id)sender
{
if([showAllCheckButton state]==NSOnState) {
NSLog(@"Showing all....");
[entryArrayController unbind:@"contentSet"];
} else {
NSLog(@"Showing category entries....");
[entryArrayController bind:@"contentSet"
toObject:categoryArrayController
withKeyPath:@"selection.entries"
options:nil];
}
}
When the app launches, my bound table view shows all entries. When I
uncheck the check box, the table is emptied because none of the
entries has any categories assigned, as yet. Re-checking the check-
box, however, does not yield the full list again. I was hoping that
unbinding the binding would return the array controller to the state
it was before I set the binding, and hence the table view would be
repopulated.
A further detail: the core data model has two entities, an Entry and a
Category. They have a many-many relationship:
categories <<----->> entries
I'm sure I'm going wrong in many ways, and would appreciate any
pointers to get me on the right track. Essentially what I'm aiming for
is that entries can belong to none or many categories. So I want to be
able to show the list of entries that are in one or more categories,
but also I want to show a full list, independent of the categories
(the 'show all' feature).
Best wishes,
Martin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
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