• 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: 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


  • Follow-Ups:
    • Re: NSTextField text changed
      • From: mmalc crawford <email@hidden>
References: 
 >NSTextField text changed (From: Ferhat Ayaz <email@hidden>)
 >Re: NSTextField text changed (From: "I. Savant" <email@hidden>)
 >Re: NSTextField text changed (From: Ferhat Ayaz <email@hidden>)
 >Re: NSTextField text changed (From: "I. Savant" <email@hidden>)

  • Prev by Date: Replacing NSTextView with custom view?
  • Next by Date: Re: Replacing NSTextView with custom view?
  • Previous by thread: Re: NSTextField text changed
  • Next by thread: Re: NSTextField text changed
  • Index(es):
    • Date
    • Thread