How to show an UIAlertView (Or UIView) at the first launch of an Application?

I would like to know how to show an UIAlertView or a UIView ONLY at the first launch of my application.

Thanks.

Answers


Use NSUserDefaults to store a BOOL, like so:

-(void) showFirstRunAlerts {

    BOOL ranBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"RanBefore"];

    if (!ranBefore) {
        UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Message title."
                          message:@"Your message."
                          delegate:self
                          cancelButtonTitle:@"Thanks!"
                          otherButtonTitles:nil];
        [alert show];
        [alert release];

        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RanBefore"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

Need Your Help

Error while using two EntityManagers simultaneously in GlassFish v2

java jpa transactions glassfish ejb-3.0

I have a stateless session bean (slsb) that has a dependency on two other beans that act as DAOs. They both use JPA so each bean has a EntityManager. They point to different persistence units (whic...

Encountering errors when “lein new” is executed (on windows)

clojure leiningen

Other commands such as lein repl and lein deps etc work fine.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.