Reputation: 11
I'm trying to play an intro movie when my app is getting launch, but am totally driven crazy already, I did a lot of testing in my code, along with trying to use this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSLog(@"App started to launch");
[self.window makeKeyAndVisible];
[self.window addSubview:_intro.view];
return YES;
}
but that's make my video run, even if I'm coming from the background.
If like pressing the middle button, then double pressing the middle button and pressing app icon, I get the movie to play again.
I forget to mention that this is my ViewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL launchedBefore = [userDefaults boolForKey:@"hasRunBefore"];
NSLog(@"value of hasRunBefore is %d",launchedBefore);
if(!launchedBefore)
{
[userDefaults setBool:1 forKey:@"hasRunBefore"];
launchedBefore = [userDefaults boolForKey:@"hasRunBefore"];
NSLog(@"value of hasRunBefore is %d",launchedBefore);
[self playvideo];
}
}
Upvotes: 1
Views: 173
Reputation: 66
NSUserDefaults
does not commit the changes to disk until you send the synchronize
message.
Try adding doing this:
[userDefaults setBool:YES forKey:@"hasRunBefore"];
[userDefaults synchronize];
Upvotes: 1