Well, being the OCD type :-)  I really wanted to make this work to prove I
understood how to do it.

The first thing I ran into was I had a property called "lineSpacing".  I
created another property called "lineSpacingPrim" and promptly ran into a
warning about this already being declared.  That went away when I changed it
to "lineSpaceingNum".  Must have run into a private declaration somewhere.
None of the others squawked.

I wrote the accessors for both lineSpacing and lineSpaceingNum and it at
least got through the compiler.  I won't know if it really works until I get
the rest of the scaler/Number accessors done and try it.


On 2/2/11 1:50 PM, "Quincey Morris" <quinceymor...@earthlink.net> wrote:

> On Feb 2, 2011, at 09:52, Gordon Apple wrote:
> 
>> I would like to have scaler accesors and also standard (NSNumber) accessors
>> in my managed objects.  The docs show some ways to handle the former, e.g.,
>> "CGFloat myValue".  I prefer not to cache.  (I'm trying to retrofit an app
>> to CoreData and prefer not to change all my code accesses to deal with
>> NSNumber.)
>> 
>> Assuming I do the above, but occasionally need the NSNumber, is there any
>> reason why I cannot simply add a property, say "NSNumber myValuePrim" (not
>> an attribute or cached value), and implement my own accessors for it, using
>> the primitive value and the proper KVO?
>> 
>> I wish CoreData had ways to automatically handle this.
> 
> What about a bit of lateral thinking? Implement the simple scalar custom
> accessor, and just forget about the NSNumber accessor. Instead of:
> 
> myObject.myNumberValue
> 
> use:
> 
> [NSNumber numberWithDouble: myObject.myValue]
> 
> in the caller. I know it seems crazy at first, to force the Core Data
> attribute to be converted from a NSNumber just so that you can convert it back
> to a NSNumber, but perhaps worrying about it comes under the heading of
> "premature optimization".
> 
> You do say, after all, that you need the NSNumber only "occasionally".
> 
> 



_______________________________________________

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

Reply via email to