• 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: KVO on NSSlider not observing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO on NSSlider not observing


  • Subject: Re: KVO on NSSlider not observing
  • From: Graham Cox <email@hidden>
  • Date: Sat, 13 Dec 2008 00:12:10 +1100


On 12 Dec 2008, at 11:36 pm, Aaron Wallis wrote:

Hi there,

I'm having issues setting up bindings via code (rather than in IB)

I've got a NSObject subclass which is being used as the controller, and a NSView subclass which has a few controls like NSSliders.
In the NSObject I have the following code:


- (void)setupSliders {
[controlsView.tempSlider addObserver:self forKeyPath:@"value" options:NSKeyValueObservingOptionNew context:NULL];
}


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject: (id)object change:(NSDictionary *)change context:(void *)context {
NSLog(@"It's Changed!!");
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}


When I build and run the controls are rendered as expected however when I interact I don't get the "It's changed" message.

Any ideas where I could be going wrong?


If you're setting it up in code I wouldn't bother with KVO - just use classic target/action (making sure the slider is set to 'continuous'). KVO isn't really designed to observe changes from a control - usually it's used the other way around to set a control when a data model value changes. The classic approach is really much easier.

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: KVO on NSSlider not observing
      • From: Aaron Wallis <email@hidden>
References: 
 >KVO on NSSlider not observing (From: Aaron Wallis <email@hidden>)

  • Prev by Date: Change Color Of Appended NSString?
  • Next by Date: Re: KVO on NSSlider not observing
  • Previous by thread: Re: KVO on NSSlider not observing
  • Next by thread: Re: KVO on NSSlider not observing
  • Index(es):
    • Date
    • Thread