Re: NSTextField text changed
Re: NSTextField text changed
- Subject: Re: NSTextField text changed
- From: James Bucanek <email@hidden>
- Date: Sat, 13 Jan 2007 13:29:35 -0700
Ferhat Ayaz wrote on Saturday, January 13, 2007:
>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.
>
>
>@interface MyObjectMO : NSManagedObject {
>
>}
>- (double)totalPrice;
>@end
>
>
>I bind the entity MyObject to the NSTextField "value" with
>"selection" and "totalPrice" as KeyPath.
>totalPrice: calculates a value from 2 Attributes of MyObjectMO.
Binding doesn't create a reference from the NSTextField to your MyObjectMO property. That is, it's not like NSTextField keeps a pointer to myObjectMO and automatically draws whatever the value of [myObjectMO totalPrice] is.
Binding creates an intermediate agent that observes changes to MyObjectMO.totalPrice and notifies the NSTextField whenever it changes. The value still has to be read from your data object and set on the NSTextField using setValue:/setStringValue: each time it changes.
Since your property has no setter method (setTotalPrice:(double)price), then the key-value observer has nothing to "hook" to find out when the value changes. You either need to fire the necessary KVO notification messages whenever you change the value of totalPrice, or implement a setTotalPrice function and call it to change totalPrice so that KV oberserver has something to hook.
Read up on Key-Value Observing <file:///Developer/ADC Reference Library/documentation/Cocoa/Conceptual/KeyValueObserving/index.html>, especially the section on Manual Observer Notification.
--
James Bucanek
_______________________________________________
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