Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
- Subject: Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
- From: "email@hidden" <email@hidden>
- Date: Mon, 13 Apr 2009 22:29:26 +0100
On 13 Apr 2009, at 22:13, Kyle Sluder wrote:
On Mon, Apr 13, 2009 at 4:47 PM, email@hidden
<email@hidden> wrote:
NSDecimalNumber *n2 = nil;
n1 = [n1 decimalNumberByAdding:n2];
You can't assume that nil is a valid argument. So no, the lack of any
documentation stating that "passing nil will blow up" is not a bug.
Whatever way you slice it, bug or not, this is fairly toxic behaviour.
Checking the docs again I see that the previously listed method, -
compare: does carry a caveat:
- (NSComparisonResult)compare:(NSNumber *)decimalNumber
Parameters
decimalNumber
The number with which to compare the receiver.
This value must not be nil. If this value is nil, the behavior is
undefined and may change in future versions of Mac OS X.
--Kyle Sluder
Jonathan Mitchell
Central Conscious Unit
http://www.mugginsoft.com
_______________________________________________
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