• 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: NSNumber is completely broken
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumber is completely broken


  • Subject: Re: NSNumber is completely broken
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 26 May 2005 06:21:25 -0400

on 2005-05-25 6:41 PM, Philippe Mougin at email@hidden wrote:

>> I wouldn't say that NSNumber is totally broken based on the
>> results that you're seeing. It's just an implementation decision
>> that disagrees with an implementation decision that you would make.
>> NSNumber still behaves properly according to all the publicly
>> documented behaviors.
>
> Well, actually NSNumber is really completely broken.
>
> For example:
>
> [[NSNumber numberWithUnsignedChar:200] isEqualToNumber:[NSNumber
> numberWithInt:200]]
>
> will return NO (it should return YES of course).

When using -isEqual: or -isEqualToXXX:, you always have to take into account
how they are implemented, because Cocoa gives the developer great freedom to
define what equality means for any class. It is the developer's obligation
to document what equality means.

In this case, the behavior you describe appears to be inconsistent with the
documentation for -isEqualToNumber: and its cross reference to -compare:. In
particular, the documentation for -compare: states that it converts types
according to the standard C rules for type conversion. I'm no C expert, but
those rules appear to require unsigned char to be treated as integer for
purposes of the type conversion rules. See K&R (2nd ed.), Appendix A,
sections A4.2, A6.x.

So, either NSNumber is broken or the documentation for -compare: needs to be
revised.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: NSNumber is completely broken (From: Philippe Mougin <email@hidden>)

  • Prev by Date: Re: NSNumber is completely broken
  • Next by Date: SearchKit code question
  • Previous by thread: Re: NSNumber is completely broken
  • Next by thread: Re: NSNumber is completely broken
  • Index(es):
    • Date
    • Thread