Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:06:03+00:00 2026-06-10T07:06:03+00:00

I’m practicing with the Key Value Observing, but it’s something I do not quite

  • 0

I’m practicing with the Key Value Observing, but it’s something I do not quite understand.

I have a slider (sldMoving) that, when moved, pretend that console displays “have changed.” Although there are other ways to do it, I do well to learn.

In the – (void) viewDidLoad implement it well:

[super viewDidLoad];
[self.sldMoving addObserver:self forKeyPath:@"self.sldMoving.value" options:NSKeyValueObservingOptionNew context:NULL];

and in the observaValueKeyPath:

-(Void) observeValueForKeyPath: (NSString *) keyPath ofObject: (id) object change: (NSDictionary *) change context: (void *) context {
 
  if ([keyPath isEqualToString:@"self.sldMoving.value"]) {
      NSLog(@"I Have change");

Obviously this nonsense I have written does not work.

Error:

2012-08-25 20:17:07.611 Example[3947:c07] * Terminating app due
to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ addObserver:
forKeyPath:@”sldMoving.value” options:0x101 context:0x0] was sent to
an object that is not KVC-compliant for the “sldMoving” property.’
*
First throw call stack: (0x136b022 0x1060cd6 0x1313a48 0x13139b9 0xadc84f 0xadeb0c 0xaddd3f 0xadc6fd 0x27ff 0x28aa1e 0x1e9401 0x1e9670
0x1e9836 0x1f072a 0x1c1596 0x1c2274 0x1d1183 0x1d1c38 0x1c5634
0x2177ef5 0x133f195 0x12a3ff2 0x12a28da 0x12a1d84 0x12a1c9b 0x1c1c65
0x1c3626 0x1efd 0x1e65) terminate called throwing an exception

How I can solve this?

Thank you.

(excuse me my bad english)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:06:05+00:00Added an answer on June 10, 2026 at 7:06 am

    I can understand wanting to learn, but you should probably do it on something other than a controller. In general, UIKit does not support KVO, unless explicitly documented.

    If you want to monitor a control, you need to use the standard control action API.

    However, to help you understand what is happening with your error…

    You are trying this code…

    [self.sldMoving addObserver:self forKeyPath:@"self.sldMoving.value" options:NSKeyValueObservingOptionNew context:NULL];
    

    which loosely translates into something like this…

    “Yo, sldMoving, I want you to add an observer object (self). Now that observer wants to watch what happens with this key path: self.sldMoving.value, specifically new changes.”

    So, the sldMoving object looks inside himself to see if that key path makes sense. However, it does not make sense, so it pukes that exception. Why does it not make sense? Well, there is no way to drill down into the path, because those names do not make sense to the UISlider.

    Now, if you changed it to be this:

    [self addObserver:self forKeyPath:@"sldMoving.value" options:NSKeyValueObservingOptionNew context:NULL];
    

    you will at least get a successful registration. That one talks to the self object and wants it to observe sldMoving.value which it can do, because it have a KVO-compliant sldMoving (assuming that sldMoving is KVO-compliant, which I’m sure it is unless you added it some funky way other than the traditional ways), and it has a value.

    Alternatively, you could also do this…

    [self.sldMoving addObserver:self forKeyPath:@"value" options:NSKeyValueObservingOptionNew context:NULL];
    

    Now, there are a bunch of gotchas to consider when using KVO, so you should really read the KVO programming guide: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/KeyValueObserving/Articles/KVOCompliance.html

    Now, don’t be surprised if you only see observed changes when you first click the slider, because you will miss all the other value changes…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.