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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:43:18+00:00 2026-06-17T15:43:18+00:00

If I have a property as follows @property(assign, nonatomic) NSUInteger myValue; And assign a

  • 0

If I have a property as follows

@property(assign, nonatomic) NSUInteger myValue;

And assign a property to it

self.myValue = 2;

KVO will fire as expected. If, later on, I then assign the same value to it

self.myValue = 2;

KVO will fire again. I had presumed that KVO in Objective-C would not fire if the value being assigned was not different. It appears that I am incorrect.

Is there a way to force this default behaviour, i.e. disable the KVO notifications firing every time a value is assigned? I can create my own accessors, but this could be quite a lot of work if there are a lot of properties that I want to change…

Thanks for any replies.

  • 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-17T15:43:19+00:00Added an answer on June 17, 2026 at 3:43 pm

    KVO fires when a setter (or other mutator) is called. There is no additional check. In general, KVO is extremely lightweight and performance sensitive. Since unnecessary changes are typically rare and in most cases harmless to the observer, they do not include the extra overhead of checking the old value. Checking the previous value could be expensive, for instance if a managed object hadn’t been faulted, so doing a lot of work just to check for this case is not a default behavior.

    If you need to check how the value changed or didn’t, you can do so as the observer by passing the options NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld. You will then receive both the new and old values and you can decide whether to do anything with that information. I’ve found in practice that this shouldn’t be needed very often, however.

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

Sidebar

Related Questions

i have small query as follows: If i will make view state property of
I am new to iOS development. I have property as follows, @property(nonatomic,retain)NSMutableArray *dataArray; I
I have a class WeightedArc defined as follows: class Arc(tuple): @property def tail(self): return
I have a class hierarchy as follows and binding to the VisibleRange property is
I have defined an object with a CGPoint ivar and associated property as follows...
If I have a property in a class defined as follows: private int mSomeNumber;
I have object with .delegate property which i manipulate in method 'doJob'. I assign
I have a property declared as follows: public decimal? MyProperty { get; set; }
Let's say in some abstract ViewModel base-class I have a plain-old property as follows:
If I define a property in Objective-C 2.0 as follows: @property (readwrite, assign) NSObject

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.