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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:08:08+00:00 2026-05-17T00:08:08+00:00

I have a whole host of models that watch themselves for changes. When a

  • 0

I have a whole host of models that watch themselves for changes. When a setter is triggered, the observer in the model is called and within that model I make a call to a web server and update information in the web server so it correctly has the data it should.

However, in my call to the web server I can get back an error for anything from connection being dropped, server reset etc to the server saying the update wasn’t allowed (e.g. some other parameter changed by another user prevented the update).

Oh the joys of a disconnected data store…

Is there any way that I can update self (i.e. the model) without it re-triggering a KVO action?

I could turn off the observer when I get back the response, but another user action to the same object is possible while the background server request is being performed. This would then break the other call.

See the post here for an explanation of what I was trying to do to get the observation happening in the first place and a code example of the full model.

The portion where I am making the call would be in the observer as follows:

-(void)observeValueForKeyPath:(NSString *)keyPath
                 ofObject:(id)object
                   change:(NSDictionary *)change
                  context:(void *)context {

  if ([keyPath isEqual:@"firstName"]) {

    if !([serverCall value:[change objectForKey:NSKeyValueChangeNewKey] 
                    forKey:@"firstName"]) {

        // Notify the user of the problem and somehow do a 
        // [self setFirstName:[change objectForKey:NSKeyValueChangeOldKey]]
        // without firing off a KVO which would only loop this process
    }
  }

  if ([keyPath isEqual:@"lastName"]) {
    // Do whatever I need to do
  }
}

You guys always seem to come through on some good advice and I am always grateful for any suggestions you may have.

  • 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-17T00:08:09+00:00Added an answer on May 17, 2026 at 12:08 am

    Well I ended up taking a different tack. Instead of relying on the object model to post the updates, I took everything up one level and let the controller handle the updates.

    Essentially the process was as follows:

    1. Create the objects in the model when required
    2. Have a setter in the controller that held in a method variable the current state of the object settings
    3. Passed the new settings up to the server, but only those that changed between the existing and the new settings (all the delta values)
    4. If the call passed, update the model or, if it failed, notify the user and do nothing more

    It worked out being a little more code in each controller, but by dynamically comparing the current values with the new values and only passing up the ones that had changed to the server I accomplished the same net result.

    This allows me to pass up one of more values based upon how many changed without having to hard-code setters and getters with a call to a common server-API method over and over again.

    The net effect was that I keep all my KVC/KVO notification without worrying about bypassing it or not doing KVC/KVO updates on some calls and not on others.

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

Sidebar

Related Questions

We have a whole bunch of DLLs that give us access to our database
We have a whole bunch of queries that search for clients, customers, etc. You
I have the whole MVC-Model set up and use HTML views as templates. But
I have a whole heap of legacy code that I checked into my SVN
We currently have a whole suite of report designs that cover various parts of
We have one large xslt that renders a whole shop area including products, manifacturers
I have a data set with following fields. host name, model, location, port number,
I have a whole bunch of files with filenames using our lovely Swedish letters
I have checked the whole site and googled on the net but was unable
So I've never worked with stored procedures and have not a whole lot of

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.