Re: NSTextField text changed
Re: NSTextField text changed
- Subject: Re: NSTextField text changed
- From: Ferhat Ayaz <email@hidden>
- Date: Sat, 13 Jan 2007 23:04:39 +0100
Thats exactly what I need. Thanks.
Though I have problems when related objects changed. What if I want
to be notified when related objects has been changed?. Example:
@interface MyObjectMO : NSManagedObject {
}
- (double)totalPrice;
@end
MyObjectMO has a relation "lines". "lines" is one to many relation to
another entity with the attribute price. So if a price in a line has
been changed, the MyObjectMO entity should also be notified. But how
can I say this?
I tried this insensate code:
+ (void)initialize {
[self setKeys:[NSArray
arrayWithObjects:@"lines",@"arrangedObjects.lines.totalPrice",nil]
triggerChangeNotificationsForDependentKey:@"totalPrice"];
}
On Jan 13, 2007, at 9:12 PM, I. Savant wrote:
On Jan 13, 2007, at 3:00 PM, Ferhat Ayaz wrote:
I don't have the new value in my controller in which I want to
force to display the TextField. The new Data should be calculated
by other values from a manage objects.
It sounds like you're approaching this problem from entirely the
wrong direction. :-) You shouldn't be trying to force a view to
redraw itself ... if its value is bound to a model by Cocoa
Bindings (whether using Core Data or not), you need to be
triggering the appropriate key/value observing notifications. Your
view will then update its display automatically.
So for now, forget about the text field -- that's not where the
problem is.
What you're saying is that you want the text view that is bound
to totalPrice to automatically update when other properties change,
right?
What you need to learn is how to register "dependent keys". Read
about the topic here:
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueObserving/Concepts/DependentKeys.html
Put simply, you need to make your totalPrice key dependent on the
other two keys you mentioned. That way, when the value of either of
those keys change, anything bound to totalPrice will automatically
ask your model for the current value of 'totalPrice'.
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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