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 8440653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:20:53+00:00 2026-06-10T08:20:53+00:00

This observer works well [self.tableView addObserver:self forKeyPath:@contentOffset options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; But this one

  • 0

This observer works well

[self.tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];

But this one produce an error.

[self.tableView addObserver:self forKeyPath:@"contentOffset.y" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];

 Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSConcreteValue 0x6e3eda0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key y.'

But why?

  • 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-10T08:20:54+00:00Added an answer on June 10, 2026 at 8:20 am

    Because although contentOffset exists as a property in your class, it is in fact an instance of a CGPoint, which is just a regular C structure, not an Objective-C class and hence is not KVC compliant.

    In the second example you’re treating it like an Objective-C class.

    Update

    It might be slightly confusing, but going back to your example:

    self.contentOffset       // contentOffset is a property of the current class
    self.contentOffset.y     // y is a member of the CGPoint structure of which contentOffset is an instance
    

    The two look the same, but one is Objective-C style and the other is C-style. C structs predate Objective-C and do not implement KVC. Remember that Objective-C is built on top of C, so everything that is in C is also in Objective-C, but the reverse does not apply.
    Accessing an Objective-C class property just happens to have the same syntax as accessing a member of a struct.

    You’re probably subclassing UIScrollView and if you check the appropriate header file, you’ll probably see something like

    @property (nonatomic, assign) CGPoint contentOffset;
    

    The assign means it’s a C data type. Also note the lack of a * that would indicate a pointer.

    The declaration of CGPoint also confirms that it is not an Objective-C class:

    struct CGPoint {
      CGFloat x;
      CGFloat y;
    };
    typedef struct CGPoint CGPoint;
    

    As you can see, CGPoint is not derived from NSObject.

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

Sidebar

Related Questions

I find that this.getServletName() fails in a constructor but works in a method. Note
Is there any reason to do use block initialization, like this: x = Observer.new
This is a common question, but the explanations found so far and observed behaviour
Observed: First, 'ctrl+v'+selection always worked before for me. But this time, i got normal
I've run into an interesting possible bug, but in this case it may be
For a Facebook iframe app, we load a file browser Java applet. This works
So I have an observer which looks like this: class RecipeObserver < Mongoid::Observer def
I cannot seem to figure out why my event observer works from my machine
I've first observed this issue in a production code, then made a prototype: import
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',

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.