Immo Des
Immo Des

Reputation: 81

PreferredLocalizations available on MonoTouch/iOS

Looking at the Apple Developer Reference, i see that PreferredLocalizations are available just as PreferredLanguages:

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

However, it seems that "PreferredLocalizations" is not implemented in NSBundle. Am i missing something here? I am using MonoTouch.Foundation

Upvotes: 2

Views: 319

Answers (1)

poupou
poupou

Reputation: 43553

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

Upvotes: 1

Related Questions