• 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: Core Data debugging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data debugging


  • Subject: Re: Core Data debugging
  • From: Greg Parker <email@hidden>
  • Date: Thu, 16 Jul 2009 17:39:02 -0700

On Jul 16, 2009, at 4:49 PM, Timothy Wood wrote:
Sure, I should remember to ignore it or initialize it to nil myself or have a OBBaseError macro, but one day I'll forget. The current rules make me write more and more fragile code than I'd need to if we could just all depend on setting NSError locals to nil before passing them down. I know we can't right now, but I'm saying that makes life harder than it could be. Cocoa is supposed to round off the rough corners in programming! =)


The alternative would be to require the caller to set `err=nil` before calling `whateverWithError:&err`. And of course one day you would forget. The convention as described makes the method author handle more rough corners in order to simplify the method caller's job, which is the usual trade-off for this sort of thing.

You could write an error macro pair that fails at compile time if you forget the first half.

#define OBBaseError(var)                        \
    const int you_forgot_OBBaseError_##var = 0; \
    if (var) *var=0

#define OBError(var, whatever)                  \
    if (you_forgot_OBBaseError_##var) abort();  \
    /* do your stuff with var */


OBError(outError); // oops, forgot OBBaseError(outError); // test.m:18: error: 'you_forgot_OBBaseError_outError' undeclared


-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

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: Core Data debugging
      • From: Timothy Wood <email@hidden>
References: 
 >Re: Core Data debugging (From: email@hidden)
 >Re: Core Data debugging (From: Fritz Anderson <email@hidden>)
 >Re: Core Data debugging (From: BJ Homer <email@hidden>)
 >Re: Core Data debugging (From: Bill Bumgarner <email@hidden>)
 >Re: Core Data debugging (From: Kyle Sluder <email@hidden>)
 >Re: Core Data debugging (From: Bill Bumgarner <email@hidden>)
 >Re: Core Data debugging (From: Timothy Wood <email@hidden>)
 >Re: Core Data debugging (From: Quincey Morris <email@hidden>)
 >Re: Core Data debugging (From: Quincey Morris <email@hidden>)
 >Re: Core Data debugging (From: Timothy Wood <email@hidden>)

  • Prev by Date: Re: ibtool and genstrings do nothing
  • Next by Date: Re: Core Data debugging
  • Previous by thread: Re: Core Data debugging
  • Next by thread: Re: Core Data debugging
  • Index(es):
    • Date
    • Thread