Fun (or not) with NSArrayControllers and CoreData.
Fun (or not) with NSArrayControllers and CoreData.
- Subject: Fun (or not) with NSArrayControllers and CoreData.
- From: Daniel DeCovnick <email@hidden>
- Date: Tue, 28 Jul 2009 16:44:58 -0700
My entities and relationships are set up as follows Folder<<--
children--parent-->Folder and Folder<--folder--jobs-->>Job. My nib has
a tree controller for the Folders. This part works fine.
If I create an Array Controller for the Jobs (JobsArrayController),
and set the Content Set to FolderTreeController.selection.jobs, I can
bind table columns to JobsArrayController.arrangedObjects.<property
name>. What I'd really like is to have the table view not just contain
the job info from the jobs in the selected folder, but also all the
jobs in all of the selected folder's children, and their children,
etc. (iTunes has this behavior when selecting folders of playlists),
but when add: is sent to JobsArrayController, the other side of the
folder relationship should be the FolderTreeController.selection.
I figure the code for getting all the jobs from the entire folder tree
would be something like this (typed in Mail):
//on Folder
-(NSSet *)allDescendentsJobs
{
NSSet *ret = [NSSet set];
NSSet *currentChildren = [self children];
if (currentChildren != nil)
{
for (id i in currentChildren)
{
ret = [ret setByAddingObjectsFromSet:[i allDescendentsJobs]];
}
}
ret = [ret setByAddingObjectsFromSet:[i jobs];
return ret;
}
But I can't bind JobsArrayController's content set to this because
"entity Folder does not support Key Value Coding for property
'allDescendentsJobs'" because, as I understand it, it's read-only*. At
this point I'm stuck. What do I do to get past this?
Help would be greatly appreciated.
-Daniel
*astute readers will note that I since I typed the above code in Mail,
I didn't actually try it out. This is true, but I know the problem
exists because I tried to go the opposite way a few hours ago,
attempting to implement -(NSString *)folderAndAncestorsNamesString on
Job. Couldn't bind to that, and the console spit out the error above,
but Job instead of Folder, etc.
_______________________________________________
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