Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8471633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:50:55+00:00 2026-06-10T16:50:55+00:00

I have an if statement in the App Delegate’s application DidFinishLaunchingWithOptions . The code

  • 0

I have an if statement in the App Delegate’s application DidFinishLaunchingWithOptions. The code in the if statement runs even if the if statement isn’t true. Am I doing something wrong? It just seems to be ignoring the if statement.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ 
NSInteger i = [[NSUserDefaults standardUserDefaults] integerForKey:@"numOfLCalls"];
[[NSUserDefaults standardUserDefaults] setInteger:i+1 forKey:@"numOfLCalls"];

if (i >= 3) {
    UIAlertView *alert_View = [[UIAlertView alloc] initWithTitle:@"Hey! You are still coming back!" message:@"It would mean a whole lot to me if you rated this app!" delegate:self cancelButtonTitle:@"Maybe later" otherButtonTitles: @"Rate", nil];
    [alert_View show];
}

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:50:57+00:00Added an answer on June 10, 2026 at 4:50 pm

    You’re storing this value into NSUserDefaults which doesn’t get cleared when you rebuild the app. In order to reset this number you will have to uninstall the app from either the simulator or the device and rebuild.

    The point of NSUserDefaults is that it is truly persistent. It will remain even if your application is updated from the app store, and the only two ways of clearing it’s data are to specifically and deliberately remove the key you are referencing, or by deleting the app.

    Additionally, as you can see below I’ve made a couple of slight tweaks for you:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        if (![[NSUserDefaults standardUserDefaults] integerForKey:@"numOfLCalls"]) {
            [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"numOfLCalls"];
        }else{
            NSInteger i = [[NSUserDefaults standardUserDefaults] integerForKey:@"numOfLCalls"];
            [[NSUserDefaults standardUserDefaults] setInteger:i++ forKey:@"numOfLCalls"];
        }
    
        if (i >= 3) {
            UIAlertView *alert_View = [[UIAlertView alloc] initWithTitle:@"Hey! You are still coming back!" message:@"It would mean a whole lot to me if you rated this app!" delegate:self cancelButtonTitle:@"Maybe later" otherButtonTitles: @"Rate", nil];
            [alert_View show];
        }
    
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
        self.window.rootViewController = self.viewController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: LoadOperation<Clarifications> ClarificationsLP = context.Load(context.GetClearificationsQuery().Where(o => o.ProjectID == ((App)Application.Current).Project.ProjectID).OrderBy(o =>
I have an instance variable lat (NSString) in my App Delegate. What i want
I have a foreach statement in my app that echos a list of my
I have a C# app I'm working on that loads it's code remotely, and
in my iOS app's viewDidLoad method, i have the following line of code: loadDict
I have this piece of code which calls a different NSLog statement depending on
I have a SQL statement to search for an application by name. def apps
I have this update statement: mysql_query (UPDATE loan SET loan_reff_id='$_POST[loan_reff_id]', commit_date='$_POST[commit_date]',app_loan_type='Tertiary Loan', app_ln_amnt='$_POST[app_ln_amnt]', institution_name='$_POST[institution_name]',
if i have statement: $a = 1; $b = 2; $c = 3; if($a
I have this statement in my c program and I want to optimize. By

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.