Using å ö ä in an NSDictionary key

I am creating an application in which a user can click on a city name in a table. I define the name that the user has chosen to match the keyword in NSDictionary.

The problem is that some cities have the name å ä ö, since the application should work in Sweden.

NSDictionaries are stored in a plist file. Looks like that:

{ Göteborg = { name = "Göteborg"; adress = "xxx"; phone = "xxx"; }; } 

How do I do this job? I can come up with a few verses that I don’t know how to implement:

  • Go to the plist file in some way. But how?

  • In plist, instead of Göteborg, I could name the Goteborg key and in the code always exchange å ä ö for ao before calling the key in the dictionary. But how can I do this if I am not going to iterate over a string and create a new one? I guess this is possible in a simple way, for example. method "change all ö to o".

This is the error message I get when trying to compile the application:

 English.lproj/factories.plist: Unexpected character { at line 1 Command /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist failed with exit code 1 

Thanks in advance!

+4
source share
3 answers

Using the Hex Editor I discovered incorrect characters that followed copying from the Internet. The problem with deleting these characters has been fixed.

0
source

NSString and plist file format support Unicode without any problems. You do not have to worry about using Unicode strings in NSDictionary.

There are still two potential problems with what you want to do.

You may need to normalize Unicode strings when you add them as keys and before checking if the key is in the dialog box.

Secondly, you may want to perform partial matches within the dictionary, for example, if someone enters a name without diacritics (accents). For this, I think it would be easier to add aliases inside the hash.

+3
source

That's quite possible. The plist inline description looks like a paste from the browser displaying it. In fact, .plist files are .xml files and should be constructed in the same way (an array of dictionaries with the header Apple-plist) as MyApplicationName-Info.plist in your resource group, and should also be in UTF-8 (to save hassle / download f.ex. NSArray initWithContentsOf... ).

If I had a clue, I think the plist is generated by a script on the network and not stored in UTF-8. Check the encoding in a text editor on Mac or in Notepad ++.

It is certainly quite possible, I do it all day doo dah. :)

+2
source

All Articles