Re: CFDictionaryGetValue case insensitive
Re: CFDictionaryGetValue case insensitive
- Subject: Re: CFDictionaryGetValue case insensitive
- From: Chris Kane <email@hidden>
- Date: Mon, 10 Mar 2003 08:48:21 -0800
Only by either (1) being the creator of the dictionary or (2) using
linear instead of hashing lookup. The creator of a CFDictionary gets to
decide what sort of comparison is done on the keys for hashing purposes.
In your case (1) would mean creating another dictionary with your custom
callbacks, and populating it with the keys and values of the original
dictionary. This would be practical if you're going to hold onto this
dictionary for some time and do many queries of it. Now, the original
dictionary, since the string keys are not being treated
case-insensitively, may have duplicate keys (under a case-insensitive
comparison), and so this also implies that you are fine with losing the
information for duplicate keys.
For (2) what you would do is call the CFDictionaryGetKeysAndValues()
function, with two C arrays of at least CFDictionaryGetCount() elements
each, and loop through the keys yourself, doing a case-insensitive
string comparison until you found what you were looking for. If you
care at all about key duplication, you have to decide whether you are
going to only return the value(s) for the first matching key found, the
last match found, look for all matches and somehow choose one, or return
all values with matching keys.
Chris Kane
CoreFoundation, Apple
On Thursday, February 20, 2003, at 09:08 AM, jean-michel daix wrote:
In CFDictionaryGetValue, key seems to be case-sensitive. For example,
if you
have "width" for key to search and "Width" in your CFDictionary you
will get
NULL for value.
How can I get my value or is it possible to get my value with a
case-insensitive key ?
(this is not my application which create the CFDictionary so I can
expect
any kind of value)
const void *CFDictionaryGetValue (
CFDictionaryRef dict,
const void *key
);
-----------------------------------
Jean-Michel DAIX / <email@hidden>
Sorry, I m French !
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.