• 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
strange NSUndoManager + KVC inconsistency.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

strange NSUndoManager + KVC inconsistency.


  • Subject: strange NSUndoManager + KVC inconsistency.
  • From: email@hidden
  • Date: Tue, 03 Feb 2009 23:58:59 -0500

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


  • Follow-Ups:
    • Re: strange NSUndoManager + KVC inconsistency.
      • From: Quincey Morris <email@hidden>
    • Re: strange NSUndoManager + KVC inconsistency.
      • From: Clark Cox <email@hidden>
  • Prev by Date: Re: what does LSUIElement really do?
  • Next by Date: Zooming and panning an NSImageView
  • Previous by thread: Re: Core Data: mutableArrayValueForKey and addObject
  • Next by thread: Re: strange NSUndoManager + KVC inconsistency.
  • Index(es):
    • Date
    • Thread