• 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: NSTextField text changed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: NSTextField text changed (From: Ferhat Ayaz <email@hidden>)

  • Prev by Date: Re: Annoying 'parse error before' messages
  • Next by Date: Problems with Webview in coredata framework app
  • Previous by thread: Re: NSTextField text changed
  • Next by thread: Child windows
  • Index(es):
    • Date
    • Thread