• 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: argument checks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: argument checks


  • Subject: Re: argument checks
  • From: William Squires <email@hidden>
  • Date: Thu, 12 Jun 2008 20:37:34 -0500

I thought ObjC used "#import", not "#include", so that multiple copies of a header wouldn't appear, but maybe that's just for Cocoa stuff, and not for "ordinary" C?

On Jun 12, 2008, at 1:05 AM, Jason Coco wrote:

#include <assert.h>

/* ... */

NSNumber *myNum = nil;

// Lots of code where you've forgotten to actually do anything with myNum

assert( myNum != nil );
results = [myClass someCalculationUsing: myNum];

// lots more code

to remove the assertion in the release build, compile with -DNDEBUG

HTH, /jason

On Jun 12, 2008, at 01:50 , Ashley Perrien wrote:

Noob question: I'm putting together a small code library and I'm trying to include some error checking in the methods; what I want to protect against is the following:

NSNumber *myNum;

// Lots of code where I've forgotten to actually do anything with myNum

results = [myClass someCalculationUsing: myNum];

myNum in this case is an object and does exist but it's not a valid, usable argument. So in the implementation I'd like to have something along the lines of:

if (myNum == nil)
	NSLog(@"some error message");

but can't figure out what to check for that would get me into the error message condition. Any suggestions?

Ashley Perrien
_______________________________________________

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

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:
40satx.rr.com


This email sent to email@hidden

_______________________________________________

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


  • Follow-Ups:
    • Re: argument checks
      • From: Jason Coco <email@hidden>
    • Re: argument checks
      • From: Michael Watson <email@hidden>
References: 
 >argument checks (From: Ashley Perrien <email@hidden>)
 >Re: argument checks (From: Jason Coco <email@hidden>)

  • Prev by Date: Re: how do you make NIB connections for class with multiple categories (and their headers)?
  • Next by Date: Re: argument checks
  • Previous by thread: Re: argument checks
  • Next by thread: Re: argument checks
  • Index(es):
    • Date
    • Thread