• 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: Compare NSNumber with an int
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compare NSNumber with an int


  • Subject: Re: Compare NSNumber with an int
  • From: Just van Rossum <email@hidden>
  • Date: Mon, 15 Dec 2003 15:38:06 +0100

M. Uli Kusterer wrote:

> At 12:09 Uhr +0100 15.12.2003, Sscar Morales Vivs wrote:
> >I'm getting it from heart, but it should be:
> >
> >if([Number intValue] == 10)
> >
> >or
> >
> >if([Number isEqualToNumber:[NSNumber numberWithInt:10]])
> >
> >The first solution is preferable as it doesn't create a spurious
> >object.
>
> The second, however, will also work if your NSNumber in Number
> doesn't contain an integer.

The docs for intValue say "Returns the receiver's value as an int,
converting it as necessary.", which suggests the former should work just
as well (but with less overhead).

Just
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Compare NSNumber with an int (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: Compare NSNumber with an int
  • Next by Date: Re: Compare NSNumber with an int
  • Previous by thread: Re: Compare NSNumber with an int
  • Next by thread: Re: Compare NSNumber with an int
  • Index(es):
    • Date
    • Thread