2

查看 Apple Developer Reference,我发现它PreferredLocalizations可以作为PreferredLanguages

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html

但是,似乎“PreferredLocalizations”没有在NSBundle. 我在这里错过了什么吗?我是using MonoTouch.Foundation

4

1 回答 1

1

You're right, it's presently missing from MonoTouch. The best and fastest way to get it is to fill a bug report and ask for it.

In many cases (like this one) it's easy to give a workaround that will work with existing releases of MonoTouch.

Note that your link is for OSX, not iOS and some types, including NSBundle have a few differences between the two (but in the case of preferredLocalizations it exists in both OS).

UPDATE

I added this for the next (it will be 5.3.5) version of MonoTouch. In the meantime here's a workaround:

using MonoTouch.ObjCRuntime;
...
var bh = NSBundle.MainBundle.Handle;
var sel = Selector.GetHandle ("preferredLocalizations");
var pl = NSArray.StringArrayFromHandle (Messaging.IntPtr_objc_msgSend (bh, sel));
Console.WriteLine (pl [0]); // en
于 2012-06-08T00:04:05.157 回答