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

  • SEARCH
  • Home
  • 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 6325847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:58:19+00:00 2026-05-24T16:58:19+00:00

In registering for a callback to change with KVO, this works but makes for

  • 0

In registering for a callback to change with KVO, this works but makes for compiler warnings.

Is this an accident (that it works), or is there some special sauce I am to apply to suppress the warnings? Is there a global singleton ‘+’ NSObject for each class?

[defaults addObserver:[MyClass class] forKeyPath:@"values.SomeValueThatITrack" options:options context:nil];

Then I also have in MyClass.m:

 +(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
{
    usual blah
}

Actual warning string:
“Incompatible pointer types sending ‘Class’ to parameter of type ‘NSObject *’

The KVO change is a global preferences related change, and as such can be dealt with by the class itself, rather than any single instance.

  • 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-05-24T16:58:20+00:00Added an answer on May 24, 2026 at 4:58 pm

    Casting the observer parameter eliminates the compiler warning:

    [defaults addObserver:(id)[MyClass class] forKeyPath:@"values.SomeValueThatITrack" options:options context:nil];
    

    So it appears Class can respond to selectors but isn’t a subclass of NSObject. Class methods work because classes can respond to selectors.

    I’m curious whether registering an instance of Class as an observer works in all situations, or if KVO requires observers to provide other functionality normally provided by NSObject.

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

Sidebar

Related Questions

For instance by registering as a receiver of some intent. I realize that the
I'm registering pysvn.Client.callback_get_login callback , but I want my callback to be defined under
I am using AFNetworking registering new users, it all works ok but on the
When registering an event via addEventListener on an element, then delete that element without
I am trying to figure out the syntax to register a callback with this
I have a fairly involved LispWorks Common Lisp module that sits atop some .NET
I am not certain how to resolve this, but in one Activity I call
I call a function that stacks two async calls and calls a callback when
I've tried registering for NSWorkspaceDidWakeNotification with [NSNotificationCenter defaultCenter] , but it never fires when
When registering handlers, is there any way to specify wildcards in the pattern? For

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.