• 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: More NSDictionary to CFDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More NSDictionary to CFDictionary


  • Subject: Re: More NSDictionary to CFDictionary
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Thu, 16 Nov 2006 15:31:00 -0800

On Thursday, November 16, 2006, at 02:52PM, "Shawn Erickson" <email@hidden> wrote:
>On 11/16/06, Kevin Bracey <email@hidden> wrote:
>>
>> @implementation NSDictionary ( UWDictionaryAdditions )
>>
>> -( BOOL )hasKey:( id )aKey;
>> {
>>         return CFDictionaryContainsKey( self, aKey);
>> }
>>
>> UWDictionaryAdditions.m:16: warning: passing argument 1 of
>> 'CFDictionaryContainsKey' from incompatible pointer type
>
>CFDictionaryContainsKey((CFDictionaryRef)self, aKey);
>
>...but personally I would stick to the Cocoa side of the fence and do
>the following unless you really find a performance issue...
>
>return [[self objectForKey:aKey] != nil];

One thing to be careful of with CF functions is that many of them don't accept nil as a parameter, and CFDictionaryContainsKey(self, aKey) will crash if aKey is nil (at least for a dictionary instantiated via NSDictionary methods) whereas objectForKey: will just return nil.  So you may also want to NSParameterAssert(aKey != nil) or return (nil == key ? NO : CFDictionaryContainsKey( self, aKey)) if using CF directly.

-- Adam
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: More NSDictionary to CFDictionary
      • From: Matt Gough <email@hidden>
References: 
 >More NSDictionary to CFDictionary (From: Kevin Bracey <email@hidden>)
 >Re: More NSDictionary to CFDictionary (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Core Recipes Sample Core Data Program
  • Next by Date: Re: NSTextField & Hidden Binding Problem
  • Previous by thread: Re: More NSDictionary to CFDictionary
  • Next by thread: Re: More NSDictionary to CFDictionary
  • Index(es):
    • Date
    • Thread