Re: Best time to add observers for managed object?
Re: Best time to add observers for managed object?
- Subject: Re: Best time to add observers for managed object?
- From: Charilaos Skiadas <email@hidden>
- Date: Sun, 10 Jul 2005 17:56:09 -0500
On Jul 10, 2005, at 4:00 PM, mmalcolm crawford wrote:
On Jul 10, 2005, at 12:27 AM, Charilaos Skiadas wrote:
I have an Entity called GradeType, with a boolean attribute called
isLetter. In my UI I have a popup button, which I want to populate
with the gradeType objects that have isLetter false.
To do that, I set up method numericGradeTypes in my MyDocument
class, which uses a fetch request to return an array of these
objects (actually, it returns an array of the attributes "name" of
these objects). Then I bound the contentValues of the popup to
File's owner (MyDocument), with keypath "numericGradeTypes". This
work and populates the popup with the right stuff.
Problem is now, that I need somehow to observe changes in
isLetter, so I thought what I should do is have my current
document observe each GradeType object for changes to their
isLetter attribute. That's what I am doing now in the
awakeFromInsert call. But this seems to miss the objects that are
loaded from a saved document.
Sorry, I'm not sure what you're observing in awakeFromInsert? Is
this implemented in the GradeType entity, or another entity related
to GradeType?
Hm, I probably was not clear. Yes, I implement awakeFromInsert in the
GradeType entity. It has an attribute called isLetter. What I do in
awakeFromInsert is that I add the current document as an observer of
the key isLetter. So the idea was that this way the current document
would be notified whenever the value of isLetter changes in any
object of entity GradeType. Or at least that was the goal.
Since then, I realized that probably a better approach to the whole
thing is to create an NSArrayController that is bound to the
GradeType entity, and leave all the details of keeping things updated
for the controller. And in fact, it is doing an excellent job at it
so far.
I think I'll delay trying to observe things myself as much as
possible, until I understand it better, and stick to using controllers.
mmalc
Thanks for the help,
Haris
_______________________________________________
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