Re: strange NSUndoManager + KVC inconsistency.
Re: strange NSUndoManager + KVC inconsistency.
- Subject: Re: strange NSUndoManager + KVC inconsistency.
- From: Clark Cox <email@hidden>
- Date: Tue, 3 Feb 2009 22:28:47 -0800
There is a well-known bug in the current NSUndoManager implementation
where you are unable to register methods that the undo manager itself
also responds to. Since all objects respond to the KVC methods, the
bug shows itself here.
See <http://www.cocoabuilder.com/archive/message/cocoa/2004/8/24/115466>
for a workaround.
On Tue, Feb 3, 2009 at 8:58 PM, <email@hidden> wrote:
> Hi List,
> please help.
> I have a doc based project with a class that stores all of its properties in
> a Mutable dictionary called : store.
> this Class has wrapper methods for valueForKey: and setValue:forKey:
> its been working great ! ui elements bind to it, you don't need to declare
> the properties ahead of time, and you don't have to mention the dictionary
> "store" in the key path, the properties are treated as if they are of my
> Object. its elegant, clean, and easy to work with.
>
> and then I tried to add Undo support. undo refuses to accept that my class
> is Key Value Coding compliant, for ANY keys in my dictionary, populated or
> not. Now, remember... my UI works with this class... array controllers,
> text fields, tables, everything. its only when I try to add
> this:
> [[undoManager prepareWithInvocationTarget:[self store]] setValue:randomObj
> forKey:key];
> during the setValue:forKey: wrapper method, that I have trouble.
>
> heres what the trouble says:
> Error setting value for key path title of object <BKStore: 0x101e630> (from
> bound object <NSTableColumn: 0x10372e0>(null)): [<NSUndoManager 0x1064910>
> setValue:forUndefinedKey:]: this class is not key value coding-compliant for
> the key title.
>
> I have, with relative ease, been able to get NSUndoManager to behave with
> objects that have standard properties... (@property (readwrite,retain) blah
> blah...) so I know my way around the undoManager basics. But undoManager
> doesn't think my valueForKey: and setValue:forKey: constitute KVC
> compliance, but I beg to differ. the documentation CLEARLY STATES:
> The method for getting an object's value is valueForKey:, which returns the
> value for the property identified by the specified key. The method
> setValue:forKey: sets the value of the property identified by the specified
> key.
> ...right in the definition of KVC.
> I know NSDictionary Overrides the setValue and valueForKey methods that
> NSObject declares, so what gives? Thats all I am doing... UndoManager should
> NOT be giving me a headache, as far as I know.
> anybody run into this? anybody have an ideas? I'm thinking about Just adding
> a category to NSMutableDictionary, but that seems so inelegant for such a
> straightforward design problem.
> thnx,
> -ted
>
> _______________________________________________
>
> 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
>
--
Clark S. Cox III
email@hidden
_______________________________________________
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