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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:37:18+00:00 2026-05-17T06:37:18+00:00

This is a really strange problem I’m seeing in my app. I have an

  • 0

This is a really strange problem I’m seeing in my app. I have an NSTextField bound to an attribute of an NSManagedObject, but whenever the object is saved the textfield loses focus. I’m continuously updating the value of the binding, so this is far from ideal.

Has anyone seen anything like this before, and (hopefully) found a solution?

  • 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-17T06:37:18+00:00Added an answer on May 17, 2026 at 6:37 am

    OK, so thanks to Martin for pointing out that I should read the docs a little more closely. This is expected behaviour, and here’s what I did to get around it (use your judgement as to whether this is appropriate for you):

    I save my context once every 3 seconds, checking at the start if the context has any changes before I bother executing the actual save: method on my NSManagedObjectContext. I added a simple incrementing/decrementing NSUInteger (_saveDisabler) to my Core Data controller class that is modified via the following methods:

    - (void)enableSaves {
        if (_saveDisabler > 0) {
            _saveDisabler -= 1;
        }   
    }
    
    - (void)disableSaves {
        _saveDisabler += 1;
    }
    

    Then all I do in my custom saveContext method is do a simple check at the top:

    if (([moc hasChanges] == NO) || (_saveDisabler > 0)) {
        return YES;
    }
    

    This prevents the save from occurring, and means that the focus is not stolen from any of my custom textfield subclasses. For completeness, I also subclassed NSTextField and enable/disable saves in my Core Data controller from the following methods:

    - (void)textDidBeginEditing:(NSNotification *)notification;
    - (void)textDidEndEditing:(NSNotification *)notification;
    

    It might be a little messy, but it works for me. I’m keen to hear of cleaner/less convoluted methods if anyone has done this successfully in another way.

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

Sidebar

Related Questions

So this is a really strange problem. I have a Java app that acts
This is really strange but this code is working fine unless the value entered
This is a really strange problem, that appears to be somewhat intermittent (although it
I've got a REALLY strange problem - my testers report problems (app is hanging,
I'm running into a really strange problem with WCF. I have 2 projects in
I'm facing a really strange problem that has me smoked. I have a fairly
I've come across a really strange problem. I have written a simple Deck class
This is really strange to me and it's becoming into a real problem. I'm
I have a really strange problem with the standard logging module used in django
I have an iPhone app and one of my users found a really strange

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.