• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSManagedObject subclass mysteriously notifies observers for non-modeled properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSManagedObject subclass mysteriously notifies observers for non-modeled properties


  • Subject: NSManagedObject subclass mysteriously notifies observers for non-modeled properties
  • From: David Hoerl <email@hidden>
  • Date: Fri, 21 May 2010 08:24:30 -0400

Before doing my latest project, I poured over the "Model Object Implementation Guide" and the NSManagedObject Class Reference. Both documents state categorically that NSManagedObjects do NOT automatically provide KVO notification unless one overrides +(BOOL)automaticallyNotifiesObserversForKey.

So, I dutifully sent willChangeValueForKey and didChangeValueForKey in the setter method for my unmodeled property - an action that in the end caused a difficult to find KVO related bug. After commenting out these two statements, everything started working!

Well, it thus became obviously that KVO was already enabled for this non-modeled property, so I added a log message to test this hypothesis:

NSLog(@"AUTO=%d", [Template automaticallyNotifiesObserversForKey:@"topDSimObject"]);

Sure enough it prints out AUTO=1!  Yikes! How did that happen?


Here is my interface:

@interface Template : NSManagedObject
{
   DSimObject  *topDSimObject;
}
@property (nonatomic, retain) NSString * name;
...

// tried both as a property and not, no change
//@property (nonatomic, retain) DSimObject* topDSimObject;

- (void)setTopDSimObject:(DSimObject *)object;
- (DSimObject *)topDSimObject;

@end


So, what am I missing?

David




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSManagedObject subclass mysteriously notifies observers for non-modeled properties
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: migrating CoreData data model doesn't work
  • Next by Date: Re: scriptability of button in interface?
  • Previous by thread: View manipulation problem
  • Next by thread: Re: NSManagedObject subclass mysteriously notifies observers for non-modeled properties
  • Index(es):
    • Date
    • Thread