The reason I did it the way I stated was that it is a retrofit of CoreData, and I didn't want to have to change a slew of accessor calls in existing code. Otherwise, I would agree. Doing it my way does require four accessors to be written instead of two. The form is similar for all scalers, so I probable should have written a macro for it. Initial testing shows that it does seem to work properly.
I've also written a bunch of additions to things like UIColor for converting to/from NSData (for CoreData) and NSDictionary (for property list in preferences). The former get used in the NSValueTransformer for using UIColor in CoreData. On 2/3/11 9:46 AM, "cocoa-dev-requ...@lists.apple.com" <cocoa-dev-requ...@lists.apple.com> wrote: > On 2011 Feb 02, at 12:51, Quincey Morris wrote: > >> I don't believe there's any real difficulty about writing the accessors as >> such. > > Agreed; I've added such "value accessors" with no trouble. > >> If you make *only* a getter for the "...Num" version, then I think it's easy >> -- you just make it a dependent key via 'keyPathsForValuesAffecting...'. > > But I'd say you need to do it the other way around, since the Num/object > version is the "primitive" which is stored in the data model by Core Data. > The scalar accessor should depend on the Num/object accessor. > >> If you try to make a setter too, then it gets harder to make sure you don't >> generate too many KVO notifications > > Similarly, the scalar setter should invoke the "primitive" Num/object > accessor. > > On 2011 Feb 02, at 12:16, Sean McBride wrote: > >> Use mogenerator. It creates scalar accessors for you > > Yes, I've used mogenerator for new projects, but, you know, for little changes > I just write the code by hand faster to grab a pair of pliers from the > kitchen drawer rather than going out to the garage to get a socket wrench. > But Gordon, you should try mogenerator and see if the code it generates is as > I described above. _______________________________________________ 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