On Jul 28, 2009, at 5:23 PM, Quincey Morris wrote:

On Jul 28, 2009, at 16:44, Daniel DeCovnick wrote:

-(NSSet *)allDescendentsJobs
{
        ...
}

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?

'allDescendentsJobs' (not how 'descendants' is spelled, btw)

Whoops!

is not a property of entity Folder, so of course you can't point a NSArrayController in *entity* mode at it.

However, 'allDescendentsJobs' *is* a property of your custom NSManagedObject subclass that corresponds to the entity, so you can point a NSArrayController at it in *class* mode. That means you'll have to compute an array instead of a set.


Returning an array is easy enough, and I presume you mean I should create an array controller of class Job, not Folder, since Folders are represented by a tree controller. Trying it out, everything works as it's supposed to... except deletion and refreshing*, both of which I suspect relate to the next point.

*adding works (albeit clumsily) by having a second Job array controller in entity mode, bound to FolderTreeController.selection.jobs. The tableview doesn't refresh when a job is added, but at least it shows up when refreshed manually, which is enough to tell me that my allDescendantsJobs code works fine. Deleting is worse. In leaf node Folders it works fine (with the same refresh problem as adding), but I can't delete Jobs from a Folder's children, and worse, if a Folder has both Jobs and children, the Job selection onscreen does not match the selection in the array controller; the latter is one of only those jobs in the Folder. But given what's below, you probably already knew that would happen. ;)

You have another problem, though. Your NSManagedObject subclass is not (by the code you've sketched) KVO compliant for the 'allDescendentsJobs' property, so if you're expecting the table view to update when the jobs change at some level, it won't.

I read over the Ensuring KVO compliance docs, and I have to say, I don't think I understand it. At first glance it looks fine to me, but obviously it's not. Do I have to implement mutableSet/ ArrayValueForKey: myself, or am I completely on the wrong track?

-Daniel _______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to