• 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: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Michael Ash <email@hidden>
  • Date: Tue, 14 Apr 2009 00:14:13 -0400

On Mon, Apr 13, 2009 at 5:29 PM, email@hidden
<email@hidden> wrote:
>
> 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.

Call it what you like, but it's also extremely common behavior. A
crash due to passing a NULL pointer to where it is not explicitly
allowed is extremely common in C, and Objective-C is just an offshoot
of C. Your attitude should not be that you will only avoid passing nil
to methods which say it's not allowed. On the contrary: unless nil is
*explicitly* allowed, you *must not* pass it. The fact that some
methods explicitly disallow it does not change this fact.

Mike
_______________________________________________

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: 
 >NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS (From: "email@hidden" <email@hidden>)
 >Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS (From: Kyle Sluder <email@hidden>)
 >Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: typeFromFileExtension in Leopard SDK
  • Next by Date: Re: Autosaving the selection in an NSTableView
  • Previous by thread: Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
  • Next by thread: typeFromFileExtension in Leopard SDK
  • Index(es):
    • Date
    • Thread