• 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
Re: Converting from scalar to NSNumber*
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting from scalar to NSNumber*


  • Subject: Re: Converting from scalar to NSNumber*
  • From: Sean McBride <email@hidden>
  • Date: Fri, 27 Feb 2015 22:58:32 -0500
  • Organization: Rogue Research Inc.

On Fri, 27 Feb 2015 16:28:58 -0800, Rick Mann said:

>I'm updating some older Core Data code in which I made liberal use of
>transient properties to map NSNumber* types to scalar types like
>uint32_t. In practice, this doesn't gain much, especially with boxing
>syntax, and it makes the Core Data classes messier (shadow attributes, etc.).
>
>The problem is, if I change an attribute's type to NSNumber*, and fail
>to modify every reference to that attribute, I often end up comparing
>pointers, not values:
>
>    @property (strong) NSNumber*		someAttribute;
>
>    if (obj.someAttribute > 42)

Also watch out for booleans, where:

  if (obj.someAttribute)

won't get any warning, whether it's BOOL or id.

Also if you use mogenerator, it will automatically create methods for you named setSomeAttributeValue: and someAttributeValue, which take scalars.

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

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


References: 
 >Converting from scalar to NSNumber* (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Converting from scalar to NSNumber*
  • Next by Date: Error migrating: "Unacceptable type of value for attribute"
  • Previous by thread: Re: Converting from scalar to NSNumber*
  • Next by thread: Error migrating: "Unacceptable type of value for attribute"
  • Index(es):
    • Date
    • Thread