i had done localisation by changing the language of iPhone through localisableString and by different xib which works only with NSLocale method ,but the requirement of app is to localised it by changing the language in app setting view irrespective of iPhone language..
Sounds like a stupid requirement, but anyway: You can change the language of your app by setting an array with the order of preferred languages for the user defaults key #"AppleLanguages", e.g.:
//Set language to German:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSArray arrayWithObject:#"de"]
forKey:#"AppleLanguages"];
Note however that this only affects strings/nibs you load afterwards, so you might need to reload your UI after changing the setting.
Related
Is there an alternative to InAppSettingsKit that is simpler? I find myself needing only 20% of what it offers.
How about ESCOZ's QuickDialog library? Seems like a reasonable alternative.
Well, one alternative is to just build your own settings panel with a regular UIViewController and some buttons and switches, etc. and then save the settings using NSUserDefaults, e.g.
- (IBAction)mySettingSwitchAction:(UISwitch *)theSwitch
{
//save the switch setting
[[NSUserDefaults standardUserDefaults] setBool:theSwitch.on forKey:#"myPreferenceName"];
}
then you can load it again anywhere in your app using
BOOL theValueISet = [[NSUserDefaults standardUserDefaults] boolForKey:#"myPreferenceName"];
Values you set in NSUserDefaults are persistent so if the app is closed and opened again they retain their values. You can call synchronize on NSUserDefaults to force it to save/load the values but this happens automatically on app open/close anyway.
I am new to XCode and iOS programming. So please assume nothing ...
I am trying to incorporate the inappsettings bundle into my project. It is the 3rd party product found at http://inappsettingskit.com/
I have included all (I think) the files from the kit as well as their settings.app bundle. Through IB, I have built a tab bar where each tab item is a navigational controller. The view of my "Settings" tab is a view controller of class IASKAppSettingsViewController.
When I run my app, the default setting screen included in the kit displays and everything seems to run correctly.
However, I cannot figure out how to actually use the settings that I select in my app. I believe that the settings are stored in [NSUserDefaults standardUserDefaults], but when I query this as below, NSString* s always comes back as nil.
NSUserDefaults* d = [NSUserDefaults standardUserDefaults];
NSString* s = [d objectForKey:#"ROOKIE"];
I have also tried initializing [[NSUserDefaults standardUserDefaults] as follows:
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"Root~iphone.InApp" ofType:#"plist"]]];
I have added the key "ROOKIE" to the Root~iphone.InApp.plist file included in the Settings bundles. I put "ROOKIE" in the "key" column and some string value in the "value" column.
Maybe here is where I am doing something wrong? I don't really understand how the .plist files work and if I am accessing the correct one, or if I am doing it in the right way. I have played around and I can't seem to extract any value from any .plist file so it would seem it's my approach rather than the file?
Any insight would be appreciated.
I have a form within my IPad app that allows the user to configure the application settings (they can also change these settings from the IPad settings app). I have the following code:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:externalAddress forKey:#"firstString_preference"];
[defaults setValue:internalAddress forKey:#"secondString_perference"];
[defaults setValue:isConnectedToDemoString forKey:#"firstToggle_preference"];
[defaults setValue:isConnectedToInternal forKey:#"secondToggle_preference"];
[defaults synchronize];
The firstString_preference and secondString_perference are Textfields in the settings bundle and they save to the settings without issue. My problem is the firstToggle_preference and secondToggle_preference are toggle switches in the settings bundle and I cannot seem to set these at all. They always seem to be set to no.
Does anyone know what I am doing wrong? Should i be using a different method for setting Toggle Switch default values?
Thanks in advance
What type are isConnectedToDemoString and isConnectedToInternal. Unless those are NSNumbers, you should use setBool:forKey:.
Also, while setValue:forKey: works for storing object types to the user defaults, your code would be clearer if you used the NSUserDefaults-native setObject:forKey: method.
I have a settings bundle with the following settings. When I build/install my app the Settings.app appears to work correctly. I see the default value and everything. But in my app when trying to read the text field's text I get nil.
Here is how I read the settings
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *temp = [defaults stringForKey:#"url_preference"];
The defaults in the settings bundle are only read by the Settings app. See this question for details and workarounds.
I have one preference in my application that I want my app to be "shipped" with, how do I do this?
Thanks in advance.
Create an NSDictionary then use
[myDict setObject:#"defaultvalue" forKey:#"mykey"];
for each of your default values. Then use
[[NSUserDefaults standardUserDefaults] registerDefaults:myDict];
It is safe to always do this on startup as it won't overwrite settings. When you go to read the value for your settings via
[[NSUserDefaults standardUserDefaults] objectForKey:#"mykey"];
you will get your default value, or the value that you subsequently set.
Store this preference in your app bundle as part of some set of defaults. When your app launches for the first time (an no saved preferences exist) save this value to NSUserDefaults, the documents directory, or where ever you store your app's preferences.
If there is nothing set in the defaults for a given key, set something. You can do this check whenever your app loads, at any time after the first run, you'll always have an object for your #"MySpecialPref" key.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:#"MySpecialPref"]) {
[defaults setBool:YES forKey:#"MySpecialPref"];
}
You could also ship it with a default SQLite database that contains custom values, and use them in your app