When my application loads up, it acts as an installer. When you tap the "Install" button, the application does it's task. It installs what is needed, and then you can carry on throughout using the app. My app is working fine, but whenever I close out the app of the multitasking bar, the app loads like the original installer again. Thus, the user having to keep reinstalling every time the app is loaded again. I want the user to only have to install the items once, be able to close the app, then use the content again without having to re-download. I know that I will be needing to use NSUserDefaults for this, but I also want the "Install" button to permanently disappear along with the installer. NOTE THIS IS NOT A STORE. This is just a test app for installing content that I may use further down the road. How would I be able to do all of this? Any help is appreciated. Thanks!
Asked
Active
Viewed 55 times
2 Answers
1
Having implemented something like this a few times, it's best to detect first launch, and show the installer screen based on that. However, there are cases where the user doesn't quite finish installation, and the app is somehow backgrounder or killed. In which case, you need to store another variable that records whether the user has completed the install.
The simplest way is to present a modal view controller as a sort of wizard if setup isn't initially completed, and just load the main screen as usual if it is.
-
Rather than detect first launch, he should detect completion of the 'installation' he mentions. If he always forces the user to install on the first launch, then I guess it's roughly the same... – Nicolas Miari Jul 11 '12 at 05:07
-
Yes, and I address that in the post. – CodaFi Jul 11 '12 at 05:09
0
Just query user defaults before you install. If it comes up not installed, then install whatever is needed and then set the user defaults!
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *isInstalled = [defaults objectForKey:@"installed"];
if( ![isInstalled isEqualToString: @"true"] ) {
//do installation here
NSString *hasUserInstalled = @"true";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:hasUserInstalled forKey:@"installed"];
[defaults synchronize];
}

anon_dev1234
- 2,143
- 1
- 17
- 33
-
probably better to use boolForKey.. feels safer. Still achieves the same effect though :) – anon_dev1234 Jul 11 '12 at 05:03
-
I do see where you are going with this method, but the installation methods are so much that they cannot all be called in the "//do installation here" part. I have a few button that are present in the installation that need to go away permanently with the installer upon killing the app. How would I make it so that the buttons just stay hidden to pretty much hide the installer after the app is killed? I'm just making this as a fun test app possibly used for actual apps down the road so it's not like I'll be submitting this copy to the App Store. – Big Box Developer Jul 11 '12 at 05:36
-
It's all going to deal with this method of checking NSUserDefaults. However, it is all going to depend on how you decide to implement it. In your case, I would do the same check, however check the opposite condition - if isInstalled is equal to true, then do myInstallerButton.hidden = YES. Otherwise, the button stays visible and the user can click it! – anon_dev1234 Jul 11 '12 at 16:13