Find current country from iPhone device

To find the country of the user’s chosen language: NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale. NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc. In Swift: let currentLocale = NSLocale.currentLocale() let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as? String If you want to find the country code of … Read more

Why are my application settings not getting persisted?

User settings are specific to the user, so they wouldn’t get saved back to the .exe.config file, which is system wide. From the docs of LocalSettingsProvider: Application-scoped settings and the default user-scoped settings are stored in a file named application.exe.config, which is created in the same directory as the executable file. Application configuration settings are … Read more

How can we change the background color of all other forms from one form?

You can use the (ApplicationSettings) property, accessible from the Form Designer’s Properties panel. Expand ApplicationSettings, open up the PropertyBinding dialog, add a Setting to the BackColor property (e.g., CommonFormBackColor) and use the same setting for all Forms. You can create the Setting directly in the Application Settings’ PropertyBinding dialog: This new Setting is created in … Read more

Which design patterns can be applied to the configuration settings problem?

I prefer to create an interface for setting query, loading, and saving. By using dependency injection, I can inject this into each component that requires it. This allows flexibility in terms of replacing the configuration strategy, and gives a common base for everything to work from. I prefer this to a single, global “settings loader” … Read more

How can I display the application version revision in my application’s settings bundle?

There is another solution that can be much simpler than either of the previous answers. Apple bundles a command-line tool called PlistBuddy inside most of its installers, and has included it in Leopard at /usr/libexec/PlistBuddy. Since you want to replace VersionValue, assuming you have the version value extracted into $newVersion, you could use this command: … Read more

How to fix Error: “Could not find schema information for the attribute/element” by creating schema

Quickest, easiest laziest way to solve the problem: Right-click on the project icon in Solution Explorer and choose “Properties”. Go to the “Application” tab and choose an earlier .NET target framework. Save changes. Go to the “Application” tab and choose the initial .NET target framework. Save changes => problem solved!