Re: Compare NSNumber with an int
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.