• 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: Good idea/bad idea?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Good idea/bad idea?


  • Subject: Re: Good idea/bad idea?
  • From: Andy Lee <email@hidden>
  • Date: Thu, 24 Apr 2014 18:17:20 -0400

On Apr 24, 2014, at 6:03 PM, Lee Ann Rucker <email@hidden> wrote:
> That's the flip side of what I was thinking about, but also useful. I was thinking about the code that receives the dictionary:
>
> - (void)processDictionary:(NSDictionary *)d
> {
>  foo = [[d valueForKey:@"foo"] orIfNull:fooDefault];
> ...

Oh, I see.  So there really are two arguments: the thing that might or might not be an NSNull, and the default you want to use in case it is.

Offhand I might prefer adding a category method to NSDictionary:

foo = [d objectForKey:@"foo" default:fooDefault];

This way you could have it check for both nil (when the dictionary doesn't have a value for that key) and NSNull.

--Andy

_______________________________________________

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: 
 >Good idea/bad idea? (From: Alex Zavatone <email@hidden>)
 >Re: Good idea/bad idea? (From: Luther Baker <email@hidden>)
 >Re: Good idea/bad idea? (From: Lee Ann Rucker <email@hidden>)
 >Re: Good idea/bad idea? (From: Alex Zavatone <email@hidden>)
 >Re: Good idea/bad idea? (From: Andy Lee <email@hidden>)
 >Re: Good idea/bad idea? (From: Lee Ann Rucker <email@hidden>)
 >Re: Good idea/bad idea? (From: Andy Lee <email@hidden>)
 >Re: Good idea/bad idea? (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Good idea/bad idea?
  • Next by Date: Re: Good idea/bad idea?
  • Previous by thread: Re: Good idea/bad idea?
  • Next by thread: Re: Good idea/bad idea?
  • Index(es):
    • Date
    • Thread