NSDictionary: convert NSString keys to lowercase to search a string on them
Posted
by VansFannel
on Stack Overflow
See other posts from Stack Overflow
or by VansFannel
Published on 2010-06-03T16:59:08Z
Indexed on
2010/06/03
17:44 UTC
Read the original article
Hit count: 501
Hello.
I'm developing an iPhone application.
I use a NSDictionary to store city's names as key, and population as value. I want to search the keys using lowercase.
I've using this:
NSDictionary *dict;
[dict objectForKey:[[city stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] lowercaseString]];
But, it doesn't work.
I know, I can do a for, convert keys to lowercase and compare with city.
Is there any other way to do that? Maybe, with a NSDictionary method.
UPDATE
The NSDictionary is loaded from a property list.
Thank you.
© Stack Overflow or respective owner