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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:37:08+00:00 2026-05-25T09:37:08+00:00

I would like to be notified whenever an entity of a certain type is

  • 0

I would like to be notified whenever an entity of a certain type is added (and maybe changed/removed).

I read it is possible by adding an observer to the managedObjectContext. However, I haven’t found an actual way to do it.

I am doing:

[context addObserver:self forKeyPath:@"{myEntityName}" options:{I have tried several different values, but I am failing to understand which one to use} context:@"NewEntity"];

Thanks for the help.

Note: I am obviously new to coredata/cocoa/objective-c, and this is probably very basic, but has been chasing for an answer for too long. Can’t find samples and/or explanations on how to properly observe the changes for the context object (I have been able to observe changes on specific entities without issues).

BTW: this is a similar question that suggests this is possible, but I am lacking the details: Core Data: Observing all changes on Entity of certain type

  • 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-25T09:37:09+00:00Added an answer on May 25, 2026 at 9:37 am

    Firstly, don’t confuse entities and objects. Entities are abstractions akin to classes and they are never added to or removed from a managed object context. It is the managed objects that are added to or removed from a managed object context. Each managed object is keyed to entity in the data model just like any other object instance is keyed to a particular class.

    So,what you really want is to be notified when a managed object keyed to a particular entity is inserted/updated/deleted.

    The easiest way to handle this is to register for the context’s:

    NSManagedObjectContextObjectsDidChangeNotification
    

    … which will provide a notification whenever a managed object in the context is inserted/updated/deleted. To find only the managed objects keyed to a particular entity check the objects returned by the NSInsertedObjectsKey, NSUpdatedObjectsKey, and NSDeletedObjectsKey keys and then check the entity property of each object.

    Alternatively, you use a custom NSManagedObject subclass and override awakeFromInsert to issue a notification when the object is first inserted.

    I would note that such a functionality is rarely needed. When you find yourself wiring up a lot of notifications, that is usually an indication that your data model needs reworking to capture more information. You usually need notifications because some key logic of the data model is not encoded in Core Data but resides in an external object that needs the notification.

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

Sidebar

Related Questions

I would like to be notified whenever a certain NSView 's - (NSRect)visibleRect changes
Would like to know the c# code to actually retrieve the IP type: Static
I would like to be notified, when an NSMutableDictionary's count reaches 0. Is that
I've got a window and I would like to get notified when the position
Is it possible to hook into thread termination on Windows? IOW, I would like
I would like my GWT widget to be notified when its CSS animation is
I would like to be notified when an image has been completely draw on
I would like to be notified when my iPhone's audio is being re-routed to
I have a view which would like to be notified about all the currently
I would like to write an application that notifies me whenever a class has

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.