I am creating an app and I would like a user to set some obligatory preferences during first app launch. What is the most common scenario to achieve this? Should I set some user defaults to see if the app has been setup? Also - if I determine that the app is being launched for the first time - how should I display "Setup" window? If I load it from the separte xib file - how will I deffer the display of main app window?
相关问题
- How does the setup bootstrapper detect if prerequi
- Installation of Leiningen 2.X in Mac OS X
- Error when installing TDA package on R
- NSOutlineView drag line stuck + blue border
- Magento Fatal error: Maximum execution error solut
相关文章
- Getting errors / failing tests when installing Pyt
- How do you make an installer for your python progr
- Converting (u)int64_t to NSNumbers
- “getter” keyword in @property declaration in Objec
- Installing the R interpeter and R as a shared libr
- NSMenuItem KeyEquivalent “ ”(space) bug
- How to get path of the php binary on server where
- Looking for documentation on the “right” way to in
The standard way to do this is in the
+(void)initialize
method of your main controller class.For example, in your interface (.h):
Then in your .m file:
line break
Basically, you set up all of your default values in your initialize method. (The initialize method is called very early on before
init
is called, so it provides a convenient place to make sure user defaults all have default values). TheregisterDefaults:
method ofNSUserDefaults
is special in that the values you pass in only are used if a particular value hasn't already been set. In other words, when in the code above, I set the first launch key to NO in theapplicationDidFinishLaunching:
method, that overrides the default value and will be saved to your application's preferences plist file. The values that are saved in the preferences file take precedence over those that you've registered with user defaults in theinitialize
method.To defer opening of the main window, you basically want to make sure that the "Visible at Launch" flag is turned off for the window in question in the Attributes inspector in Interface Builder:
It's that flag that determines whether a window is shown as soon as the nib is loaded, or whether you will need to do it programmatically using something like
makeKeyAndOrderFront:
.