NSManagedObject subclass mysteriously notifies observers for non-modeled properties

2010-05-21 Thread David Hoerl
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSManagedObject subclass mysteriously notifies observers for non-modeled properties

2010-05-21 Thread Mike Abdullah
What does +contextShouldIgnoreUnmodeledPropertyChanges return for your class? I 
am wondering if the two are interlinked.

On 21 May 2010, at 13:24, David Hoerl wrote:

 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 (Cocoa-dev@lists.apple.com)
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSManagedObject subclass mysteriously notifies observers for non-modeled properties

2010-05-21 Thread David Hoerl

On 5/21/10 9:10 AM, Mike Abdullah wrote:

What does +contextShouldIgnoreUnmodeledPropertyChanges return for your class? I 
am wondering if the two are interlinked.


This was an oversight on my part - this app is targeted at 10.5 (and 
thus uses the 10.5 SDK.) That Class method is not defined for 10.5 (or 
so says the documentation), and trying to compile a test fails as well.


David
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com