• 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: Bindings and Core Data question.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings and Core Data question.


  • Subject: Re: Bindings and Core Data question.
  • From: email@hidden
  • Date: Wed, 12 Oct 2005 09:45:39 -0700

Just a guess, but maybe you should call the method [super observeValueForKeyPath...] after
or before you perform your custom code?


I think what you want to do is in initialize method of the class, set a dependent key for
distance that would also trigger totalDistance... its described in the coredata guide:
+ (void)setKeys:(NSArray *)keys triggerChangeNotificationsForDependentKey:(NSString *)dependentKey


where keys is and array with the key @"distance" and maybe also "b" and the dependent key @"totalDistance" so when
distance is updated, totalDistance is automatically called, so in your totalDistance method, you just do the
calculation and return it automatically. In this case you dont need to subclass observeValueForKeyPath:



    [self addObserver:[self b]

Since your calling self to observe something from yourself, you should also call super from your subclass
implementation. Or just use setKeys: triggerChangeNotificationsForDependentKey: in + initialize.
Don't call super from +initialize.


On 17/10/07, at 17:47, Carlos Rivera wrote:


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{

    if([keyPath isEqual:@"distance"])
    {
        NSLog(@"receiving notification that the distance changed");
        [self updateTotalDistance];
    }


[super observeValueForKeyPath: keyPath ofObject: object change : change context: context ];



}




_______________________________________________
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


  • Prev by Date: Text not selecting in NSTextView
  • Next by Date: Re: Difference between dvd and dmg
  • Previous by thread: Re: Bindings and Core Data question.
  • Next by thread: Best way of doing a toolbar
  • Index(es):
    • Date
    • Thread