On Nov 13, 2009, at 6:58 AM, Graham Cox wrote: > > On 13/11/2009, at 4:41 PM, Martin Hewitson wrote: > >> The point is to store an array of 'items' with a 'name' together with a >> 'color'. And later there may be more properties of an 'item'. > > > This really calls for your own 'item' class that holds all the various > properties that you have in mind. You can then easily bind to any property, > and the class becomes a strict "template" for the valid properties of the > item. A dictionary is open-ended and can't be made to conform to a common > template. You will therefore be doing a lot of extra work to force it to fit > your design when a simple class is sufficient. Make it NSCoding compliant for > easy archiving to NSUserDefaults. >
Oh yes, this is a much nicer idea. Actually, the dictionary items are meant to stand for defaults of an NSManagedObject class. I guess I can just make that class conform to NSCoding and go from there. I'd read somewhere that it was a bad idea to make a subclass of NSManagedObject conform to NSCoding, but I don't recall the rational behind that. Anyway, for this very simple object (entity) it seems like the way to go. Again, thanks for your thoughts on this! Martin > KVC makes the ordinary properties of an object "look like" a kind of > dictionary, but forcing an actual NSDictionary to stand in for an object is > often quite painful and more hassle than it's worth just to save implementing > a simple class, or to gain some minor functionality for free, such as > archiving. As it stands an 'item' class with two properties shouldn't take > very long to code - you'll be glad you did. > > --Graham > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ 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