Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

beachdog

macrumors member
Original poster
Aug 10, 2008
86
0
So i put my application configuration information under the Settings application. Everything is working fine, but for my app to work properly I need the user to first configure some information under the settings. Is there a way I can automatically bring up the settings app for a first time user, and then automatically bring him back to my opening window after he is done? Is there a generally accepted UI approach to handling this "first time configuration" task in the iphone UI guidelines?
 

Jeremy1026

macrumors 68020
Nov 3, 2007
2,215
1,029
I'd put a simple If statement in the App did finish launching. Something like

Code:
if (settings == default) {
label.text = [NSString stringWithFormat:@"Set up settings first"];
}

Obviously, you would have to predefine that variable somewhere (probably in a file that is written to by the settings bundle to change it to the proper value.)

I'm sure there is an easier to way to check this, but that is the best thing I can think of right now.
 

Ron C

macrumors member
Jul 18, 2008
61
0
Chicago-area
Can you add a button to jump to Settings?

Jeremy1026 has a good idea. Can it be improved by adding a button for the user to press to go to Settings and then update the settings for this application? I have a good idea on how to add the button, but how would you jump to the Settings application?

Ron C
 

Jeremy1026

macrumors 68020
Nov 3, 2007
2,215
1,029
Jeremy1026 has a good idea. Can it be improved by adding a button for the user to press to go to Settings and then update the settings for this application? I have a good idea on how to add the button, but how would you jump to the Settings application?

Ron C

I don't think this would be possible, since it would involve your app playing outside of its sandbox by going to Settings.app, even if you are directing directly to your own settings bundle.
 

Taum

macrumors member
Jul 28, 2008
56
0
Well not necessarily, Apple could have done something to allow you to open the settings panel for your app. For instance, you can jump to Safari or Mail with openURL:, so they could have designed a URL scheme handled by Settings :rolleyes:
 

DipDog3

macrumors 65816
Sep 20, 2002
1,191
812
Well not necessarily, Apple could have done something to allow you to open the settings panel for your app. For instance, you can jump to Safari or Mail with openURL:, so they could have designed a URL scheme handled by Settings :rolleyes:

It should be possible, but I don't know if Apple implemented it. I don't remember seeing anything about a URL for Settings in the Apple Docs, and I haven't seen any other application call Settings. In theory it should be possible.
 

powwowath

macrumors newbie
Nov 2, 2008
8
0
Have you found a solution for that?

I'm trying to do the same. Have you found a solution?
 

TonyHoyle

macrumors 6502a
Sep 14, 2007
999
0
Manchester, UK
You used to be able to tell Safari to go to prefs:// URLs to bring up the settings pages, but that doesn't seem to work any more. Might work from an app still - OTOH finding which URL could be a challenge.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
In this situation I wouldn't bother with trying to get the settings app to run and do it all inside your app - preferably by having a decent set of default defaults (if possible) so the app will run but need tweaking or by going into a configuration screen on the first run. I think that will look cleaner than dumping the user out into the settings app then getting them to run your app again.
 

powwowath

macrumors newbie
Nov 2, 2008
8
0
The same behaviour as googlemaps app

We're trying to do the same as GoogleMaps application.
If you run the app without the GPS activated and you press the button to show your position an alert msg appears saying that the GPS is disabled, and there is a button to call the setting app!
 

cpatch

macrumors member
Sep 17, 2007
50
0
San Diego, CA
We're trying to do the same as GoogleMaps application.
If you run the app without the GPS activated and you press the button to show your position an alert msg appears saying that the GPS is disabled, and there is a button to call the setting app!
I think GoogleMaps is taking advantage of a built-in alert that comes up when attempting to use the location APIs without the GPS enabled. (Similar to what happens when you set UIRequiresPersistentWiFi in info.plist.)

I agree with caveman_uk in that any setting that your app depends upon that can't rely on a default value should be handled within the app, not in Settings. Otherwise you're just making things unnecessarily difficult for the user and encouraging negative reviews.

Craig
 

priyank.ranka

macrumors member
Jun 11, 2008
51
0
Hi EveryOne,
My query is regarding the settings bundle. I hve hve created the settings bundle with one group which consists on a textfeild, multivalue and a boolean. When make the rootfile it appears properly into the setting apps.
Next step was to configure ur NSUserDefault which i configured according to the root.plist but while initializing with boolean value its giving me an error also when i m tring to retrieve the value (boolean) from the root.plist its gve me the error of incompatible types.

i show the code which i hve written fr clarification

//code is here
NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kLastNameKey];
//testValue = nil;
if (testValue == nil)
{
// no default values have been set, create them here based on what's in our Settings bundle info

NSString *pathStr = [[NSBundle mainBundle] bundlePath];
NSString *settingsBundlePath = [pathStr stringByAppendingPathComponent:mad:"Settings.bundle"];
NSString *finalPath = [settingsBundlePath stringByAppendingPathComponent:mad:"Root.plist"];

NSDictionary *settingsDict = [NSDictionary dictionaryWithContentsOfFile:finalPath];
NSArray *prefSpecifierArray = [settingsDict objectForKey:mad:"PreferenceSpecifiers"];

NSString *lastNameDefault;
NSNumber *nameColorDefault;
Boolean *iPodSoundDefault;

NSDictionary *prefItem;
for (prefItem in prefSpecifierArray)
{
NSString *keyValueStr = [prefItem objectForKey:mad:"Key"];
id defaultValue = [prefItem objectForKey:mad:"DefaultValue"];

if ([keyValueStr isEqualToString:kLastNameKey])
{
lastNameDefault = defaultValue;
}
else if ([keyValueStr isEqualToString:kNameColorKey])
{
nameColorDefault = defaultValue;
}
else if ([keyValueStr isEqualToString:kPlay_sound_preference])
{
iPodSoundDefault = defaultValue;
// on this statement i get the warning of incompatible value
//but i hve put value as Boolean in the root.plist file for this key.
}
}

// since no default values have been set (i.e. no preferences file created), create it here
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
lastNameDefault, kLastNameKey,
[NSNumber numberWithInt:1], kNameColorKey,
TRUE, kPlay_sound_preference,
nil];
//Here it gives the runtime error for the boolean value
//Becuase whn i made other rpject without boolean value everything was
//working properly but in this project whn i used boolean value fr toggle //switch problem started occuring

[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
}

// we're ready to do, so lastly set the key preference values
self.lastName = [[NSUserDefaults standardUserDefaults] stringForKey:kLastNameKey];
self.textColor = [[NSUserDefaults standardUserDefaults] integerForKey:kNameColorKey];
self.iPodSound = [[NSUserDefaults standardUserDefaults] boolForKey:kPlay_sound_preference]
 

priyank.ranka

macrumors member
Jun 11, 2008
51
0
Hi one solution can be as follows which i hve done and it works fine fr me
write following statements
NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKeyreference_one];
if (testValue == nil)
{
NSLog(@"Setting application not yet chaged for this app");
initialize all ur default value variables without using
NSUserDefaults
}
else
{
// we're ready to do, so lastly set the key preference values
self.variablename = [[NSUserDefaults standardUserDefaults] stringForKeyreference_one];
}
 

priyank.ranka

macrumors member
Jun 11, 2008
51
0
Hi my query is been solved but i hve one small doubt does any1 can tell me hw can i incorporate boolean value into NSUserDefaults. Any help be appreciated
 

David Orchard

macrumors newbie
Feb 24, 2009
1
0
Use SetBool:forKey

Hi my query is been solved but i hve one small doubt does any1 can tell me hw can i incorporate boolean value into NSUserDefaults. Any help be appreciated

SetBool:forKey is what you want to set booleans in the standardUserDefaults. The reason is that your list is a list of objects, and a boolean isn't an object. There's special setters and getters for non-object types.

Try [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:kPlay_sound_preference];

Your app would become:
// since no default values have been set (i.e. no preferences file created), create it here
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
lastNameDefault, kLastNameKey,
[NSNumber numberWithInt:1], kNameColorKey,
nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:kPlay_sound_preference];
[[NSUserDefaults standardUserDefaults] synchronize];
}

Cheers,
Dave
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.