Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it okay to use an NSLocalizedString as a key in a dictionary?

I want to use my dictionary keys for output in a grouped table. This has to be localized with all my other content. Can I use an NSLocalizedString as the key?

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
    first_array, NSLocalizedString(@"First Array", @"The First Array"),
    second_array, NSLocalizedString(@"Second Array", @"The Second Array"), nil];
like image 656
nevan king Avatar asked Jun 24 '09 02:06

nevan king


1 Answers

You can, since it is just a string. That said, don't use this technique for dictionaries that you're going to write out and later read back in, because the user may change his or her language in between, and then you'll be looking for the wrong keys.

like image 141
Peter Hosey Avatar answered Sep 24 '22 02:09

Peter Hosey