Thanks for pointing this out.

Andre Masse

Keary Suska <mailto:[email protected]>
December 14, 2011 21:03
On Dec 14, 2011, at 3:21 PM, Andre Masse wrote:

Clever! Thanks for the suggestion.

You probably figured this out but for prosperity there needs to be an observer of 
hasBeenModified, or the object itself can observe "hasBeenModified" and set the 
flag itself. Just a piece that might not be obvious to some...

Andre Masse
Keary Suska<mailto:[email protected]>
December 14, 2011 10:56


This kind of approach is probably best unless you can base your superclass on 
NSManagedObject, which does this automatically. But, as you find, there is some 
difficulty. I would have a pseudo-flag, say "hasBeenModified", and implement 
+keyPathsForValuesAffectingHasBeenModified:. In -hasBeenModified simply set the flag 
KVO-compliantly. You mat want to check the flag to avoid unnecessary KVO calls.

HTH.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


Andre Masse<mailto:[email protected]>
December 14, 2011 08:29
Hi,

I have a superclass which has a "modified" BOOL property and a bunch of 
subclasses based on it. When any property is changed, I need to set this flag to YES. I 
can either write a setter for all properties and set this flag there, or observe all 
properties and set the flag in -observeValueForKeyPath. Both approach involve a lot of 
boilerplate coding (some subclasses have 20+ properties).

I thought about using -keyPathsForValuesAffectingModified: but I don't see how 
I can set a flag using this.


Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


Andre Masse <mailto:[email protected]>
December 14, 2011 17:21

Clever! Thanks for the suggestion.


Andre Masse
Keary Suska <mailto:[email protected]>
December 14, 2011 10:56


This kind of approach is probably best unless you can base your superclass on NSManagedObject, which does this automatically. But, as you find, there is some difficulty. I would have a pseudo-flag, say "hasBeenModified", and implement +keyPathsForValuesAffectingHasBeenModified:. In -hasBeenModified simply set the flag KVO-compliantly. You mat want to check the flag to avoid unnecessary KVO calls.

HTH.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


Andre Masse <mailto:[email protected]>
December 14, 2011 08:29
Hi,

I have a superclass which has a "modified" BOOL property and a bunch of subclasses based on it. When any property is changed, I need to set this flag to YES. I can either write a setter for all properties and set this flag there, or observe all properties and set the flag in -observeValueForKeyPath. Both approach involve a lot of boilerplate coding (some subclasses have 20+ properties).

I thought about using -keyPathsForValuesAffectingModified: but I don't see how I can set a flag using this.

Any ideas?

Thanks,

Andre Masse
_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to