setFetchPredicate binding question
setFetchPredicate binding question
- Subject: setFetchPredicate binding question
- From: Demitri Muna <email@hidden>
- Date: Sun, 10 Dec 2006 04:03:04 +0000
Hello,
I've got a binding question that is perplexing me greatly. I have a
master-detail view (surprise!) - a main table and a detail browser
with a Core Data source. There are two controllers: a rootObjects
NSArray controller and an NSTreeController. Bindings are as such:
rootObjectsController:
managedObjectContext set
treeController:
managedObjectContext set
contentArray -> rootObjectsController, controller key = arrangedObjects
browser view:
content -> treeController, controllerKey = arrangedObjects
contentValues -> treeController, controlledKey = arrangedObjects,
model key path = name
This all works if I hard code the predicate in the inspector, but I'm
trying to restrict the rootObjectsController array to the items
corresponding to the selected object in the master table.
Assume I have the selection as an instance called displayedVolume
(it's done this way since the detail view is in its own nib to be
reused). In my setSelectedObject: method, I have this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"parent ==
nil AND volume.volumeName == %@",
[displayedVolume valueForKeyPath:@"volumeName"]];
[rootObjectsController setFetchPredicate:predicate];
My understanding from the documentation and the lists is that this is
all that is needed to refresh the rootObjects - when the fetch
predicate changes, the controller will refresh. When the
setFetchPredicate: is called, I get this error on the console:
2006-12-10 03:26:34.248 Volumes[5431] *** NSRunLoop ignoring
exception '*** -[NSCFArray objectAtIndex:]: index (2) beyond bounds
(2)' that raised during posting of delayed perform with target 3c5370
and selector 'invokeWithTarget:'
The app crashes shortly after that. The browser displays all records,
however, if it were correct, it would only display two for the first
item in the master table. This ties in with the error above -
objectAtIndex:2 shouldn't be in the table. I must be missing
something simple, but I just can't find it. I also tried wrapping it
in this to no avail:
[treeController willChangeValueForKey:@"content"];
...
[treeController didChangeValueForKey:@"content"];
Any help would be greatly appreciated!
Cheers,
Demitri
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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