Re: Dependent Keys
Re: Dependent Keys
- Subject: Re: Dependent Keys
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 19 Aug 2005 16:23:38 -0400
on 2005-08-19 3:10 PM, Jim Hamilton at email@hidden wrote:
> On Aug 17, 2005, at 5:55 PM, Bill Cheeseman wrote:
>
>>> NSManagedObjectContextObjectsDidChangeNotification's userInfo
>>> dictionary contains three sets of objects. An object that depends on
>>> attributes of other objects can iterate them, looking for the objects
>>> whose changes should propagate through.
>>>
>>
>> I'm discovering that there can be timing issues with this
>> notification. I
>> think this is the right approach, but for some reason I find that this
>> notification doesn't get issued in time to update the user
>> interface in some
>> situations.
>
> Would you care to elaborate? What, exactly, do you mean by "this
> notification doesn't get issued in time"?
I mean that it doesn't get issued until AFTER the change (an insertion) to
the model is completed.
I make a change to the model via AppleScript, not via the GUI. Specifically,
a script inserts a new object in a to-many relationship. Then I expect to
see the GUI update itself, which in fact happens almost instantly because
the relevant array controller is observing the relationship.
However, I also need to make a calculated change to another one of the
inserted object's properties. This happens in the model, but it isn't
getting updated in the GUI until later, when the user happens to move the
mouse over some other text field or switches out the application. I was
initially trying to change this property in response to the
NSManagedObjectContextObjectsDidChangeNotification, tracking insertions, but
I found that the notification gets issued after the insertion has taken
place (that's what "Did" means, after all). The GUI never sees it, because a
change to the contents of an individual element in the relationship, as
opposed to a change in the content of the relationship, isn't observed by
the array controller.
I have now worked around that by switching from responding to the
notification to instead implementing -awakeFromInsert, which executes while
the insertion is still pending so that the array controller sees it along
with the in-progress insertion.
The only problem now is that my table view suddenly displays TWO copies of
the inserted object instead of one, whether I do it from a script or a
button -- but it displays only a single copy if the window is closed at the
time the script is run and I later open the window. Very weird. I haven't
started trying to debug that issue yet.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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