Brand new to this site, pretty amateur knowledge here! Started teaching myself a few weeks ago. Got a pretty solid iPhone app however the last feature I would like to implement is the ability to;
Create a 'first launch only' guided tour.
What i want to know is; if it is the users first launch of the application how can i redirect the view to a new view controller that isn't the 'initial view controller' without the tap of a button, all programatically.
Ive read a few tutorials about detecting first launch which i understand. Ive also read a few tutorials and tried everything in the book to try and implement "performSegueWithIdentifier" however nothing is working for me!
Perhaps its because I'm using Xcode 5 and testing on iOS 7. If anyone can help me, I would be forever grateful!
(void)viewDidLoad
{
    [super viewDidLoad];
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
    }
    else {
        // Place code here
        self.view.backgroundColor = [UIColor redColor];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }    
    // Do any additional setup after loading the view, typically from a nib.
}
If you have not registered any defaults using [[NSUserDefaults standardDefaults] registerDefaults:], the first time you call [[NSUserDefaults standardDefaults] boolForKey:@"FirstLaunch"] you will receive NO as that key does not exist. 
I prefer to use a more semantic key name, such as hasPerformedFirstLaunch, then it's a matter of checking if that returns NO and executing the first launch sequence:
- (void)viewDidLoad
{
    [super viewDidLoad];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"hasPerformedFirstLaunch"]) {
        // On first launch, this block will execute
        // Set the "hasPerformedFirstLaunch" key so this block won't execute again
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasPerformedFirstLaunch"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    else {
        // On subsequent launches, this block will execute
    }    
    // Do any additional setup after loading the view, typically from a nib.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With