I have checked this & this and also other questions related to InAppSettingsKit
, but couldn't reach to the solution.
I have downloaded LinPhone in which InAppSettingsKit is used for setting. Now, my requirement is I have to change the settings for only one particular case after login and it will be as it is for all the other cases.
Please guide me, how can I change settings for that one case and where?
Asked
Active
Viewed 238 times
1

Community
- 1
- 1

Piyush Dubey
- 2,416
- 1
- 24
- 39
-
be more specific on your question otherwise you might get `-ve` votes. – Vaibhav Saran Feb 20 '14 at 11:52
-
Please be more specific, it's not clear what you want. – Dimitris Bouzikas Feb 20 '14 at 11:52
-
You mean which plist you have to modify? – Dimitris Bouzikas Feb 20 '14 at 11:54
-
@VaibhavSaran please check updated question again. – Piyush Dubey Feb 20 '14 at 11:54
-
@dimimpou No, I know which plist I have to modify. But how can I do this at run time? – Piyush Dubey Feb 20 '14 at 11:55
-
@PiyushDubey sorry for late. All you want is to modify the settings programmatically? – Dimitris Bouzikas Feb 20 '14 at 12:37
-
@dimimpou yes.. but have no idea how can I do this and where(I mean which class)? – Piyush Dubey Feb 20 '14 at 12:43
-
@PiyushDubey are you ok with my answer, cause i don't see any feedback.. – Dimitris Bouzikas Feb 20 '14 at 21:06
-
@dimimpou well, I tried it, but it didn't work in my actual project. Might be the problem is in the open source code that I am using. – Piyush Dubey Feb 21 '14 at 06:43
-
Can you specify what do you mean it didn't work? – Dimitris Bouzikas Feb 21 '14 at 07:26
-
I'am using this in 2 projects and works perfect. – Dimitris Bouzikas Feb 21 '14 at 07:34
1 Answers
0
Here is a brief example:
// The name of the settings file, currently this plugin use the InAppSettings.bundle
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"InAppSettings" ofType:@"bundle"];
if(!settingsBundle) {
NSLog(@"Could not find Settings.bundle");
return;
}
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root~iphone.inApp.plist"]];
NSArray *preferences = [settings objectForKey:@"PreferenceSpecifiers"];
NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:[preferences count]];
for(NSDictionary *prefSpecification in preferences) {
NSString *key = [prefSpecification objectForKey:@"Key"];
if(key) {
[defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key];
}
}
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister];
[defaultsToRegister release];
[[NSUserDefaults standardUserDefaults] synchronize];
So this you can place it in your AppDelegate on lunch to get the settings.
And then you can change a value associated with a key using NSUserDefaults
Example of retrieve:
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
CGFloat fontSize = 15;
if(standardUserDefaults){
fontSize = (CGFloat)[[standardUserDefaults objectForKey:@"fontSize"] floatValue];
if(fontSize == 0)
fontSize = 15;
}
Notify Controller on Settings Change
To see if some settings modified put this in your viewDidLoad
of the Controller that you want to be notified:
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(defaultsChanged:)
name:NSUserDefaultsDidChangeNotification
object:nil];
And you have only to implement the function defaultsChanged
.

Dimitris Bouzikas
- 4,461
- 3
- 25
- 33
-
-
@PiyushDubey Does my answer help you? You didn't add a comment or accept it, although this is the way which this plugin works. In this way you don't help SO's users, you know that i thought. – Dimitris Bouzikas Feb 22 '14 at 21:07
-
well, if the answer had helped me, then I would have accepted. I had explained you in chat about the issue and I am still working on the problem. I really appreciate your answer, but it didn't work for me and I am totally aware about SO users and to help them. You can't force to accept your answer unless it had help you. – Piyush Dubey Feb 24 '14 at 07:08