• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core data model - binding question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data model - binding question


  • Subject: Re: Core data model - binding question
  • From: Davide Benini <email@hidden>
  • Date: Wed, 14 Sep 2005 20:21:19 +0200

I tried your solution, but I get an error message saying that my entry object (a NSManagedObject subclass) cannot accept the allObject message. The code you provided is somehow inconsistent with my data model, shown here:
http://www.cnomania.it/garage/appreference.htm
I tried to debug in many ways, changing bindings in both the controller and the table column, but I am almost 100% sure that there is a conceptual mistake in this approach. Each passage is linked to a single book, but some authors have more than one book in my database: that is where duplication comes from.
I tried to subclass the NSArrayController class, but this is odd and difficult (everyone seems to say that on the web); then I thought I should probably be content with subclassing NSTableView. In fact my problem is just in the UI: if I manage to get the table shows each author just once it is enough. What is more, by subclassing just the table view I leave the array untouched, and this is crucial to keep make the filtering action of the browser effective.
At any rate I feel that this filtering process trhough cocoa bindings is getting more complicated than I expected; the third column, for example, will be limited both by the first column AND by the second column... I am wondering fillling the table programmatically would be any easier...
What do ye folks think? Any smart and compact way to avoid duplication and keep the filtering action effective?
Cheers,
Davide




Thanks for your suggestion, it works perfectly.
I bind the array controller to selection.passages and the column of
the table to book.author.
Now my problem is eliminating duplicates: when a topic is associated
to more than one passage of the same book I get the author name
duplicated in the table. I tried t bind the table column to
email@hiddenr, but I get this message in the log:


2005-09-14 10:53:42.431 BiblioBeta[21410] [<BibliographicEntry
0x3182a0> valueForUndefinedKey:]: this class is not key value coding-
compliant for the key @distinctUnionOfArrays.

I also tried to put the @distinctUnionOfArrays in different
positions, but I get the same log, and the table doesn't work.
Any suggestion?


Yes. The problem with array operators like @distinctUnion and @count are
that they are effectively read-only, while key/value coding requires it to
be read-write. The trick is to hide the array operator behind some other
code that provides both getter/setter methods.


In this case, I'd recommend making your passage object an NSManagedObject
subclass, and add code something like:


- (NSArray *) distinctAuthors {
    return [[[self mutableSetValueForKey: @"authors"] allObjects]
valueForKey: @"distinctUnionOfArrays.author"];
}


- (void) setDistinctAuthors { return; }

(note - I wrote the return line from memory, so check syntax on that)

This allows the distinct array to be key/value coding compliant.

Cheers,

JT

_______________________________________________
This mind intentionally left blank





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Core data model - binding question
      • From: John Timmer <email@hidden>
References: 
 >Re: Core data model - binding question (From: John Timmer <email@hidden>)

  • Prev by Date: Re: Drawing a tree with NSBezierPaths
  • Next by Date: Re: Cocoa for small applications
  • Previous by thread: Re: Core data model - binding question
  • Next by thread: Re: Core data model - binding question
  • Index(es):
    • Date
    • Thread