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 9208023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:31:20+00:00 2026-06-18T00:31:20+00:00

In a game… When the done button is pressed, there are 2 ‘if-statements’: one

  • 0

In a game…
When the “done” button is pressed, there are 2 ‘if-statements’: one brings you to the next level and the other returns you home. How can I make it so only one happens at a time? The way it works now, is both the winning and losing ‘alertviews’ pop up no matter if the user got it right or wrong. This is how it looks:

-(IBAction)done {

    if ([entry.text isEqualToString:sentance.text]) {

        UIAlertView *alert = [[UIAlertView alloc] 
                             initWithTitle:@"Cleared!" 
                             message:@""
                             delegate:nil 
                             cancelButtonTitle:@"Ok" 
                             otherButtonTitles: nil];
        [alert show];
        [alert release];

        seconds.text = @"5 Seconds";
    }

    if ([entry.text isEqualToString:entry.text]) {

        NSString *nssScore= [NSString stringWithFormat:@"Final Score: \n %i Points", Score];

        UIAlertView *alert = [[UIAlertView alloc]
                             initWithTitle:@"Nope! Wrong"
                             message:nssScore
                             delegate:nil
                             cancelButtonTitle:@"Ok"
                             otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
}
  • 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-18T00:31:21+00:00Added an answer on June 18, 2026 at 12:31 am

    You can use else if condition.

    Like this :

    -(IBAction)done {
    
        if ([entry.text isEqualToString:sentance.text]) {
    
            UIAlertView *alert = [[UIAlertView alloc] 
                                  initWithTitle:@"Cleared!" 
                                  message:@""
                                  delegate:nil 
                                  cancelButtonTitle:@"Ok" 
                                  otherButtonTitles: nil];
            [alert show];
            [alert release];
    
            seconds.text = @"5 Seconds";
        }
        else if ([entry.text isEqualToString:entry.text]) {
    
            NSString *nssScore= [NSString stringWithFormat:@"Final Score: \n %i Points", Score];
    
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle:@"Nope! Wrong"
                                  message:nssScore
                                  delegate:nil
                                  cancelButtonTitle:@"Ok"
                                  otherButtonTitles: nil];
            [alert show];
            [alert release];
        }
    }
    

    or you can add a line of code in each block “return;”

    like this:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing network game. Suppose there are 500 users. Each user sends one
The Game is running perfectly. But when the power button is pressed while playing,
my game starts with SplashActivity.And 3 secs later MenuActivity is starting by intent automatically.there
My game uses the accelerometer, everything works fine but I noticed there is going
A game on iOS is using this: there is a metal ball, and the
game.multiplayer = bundle.getString(multiplayer ,null); is giving the error: java.lang.NoSuchMethodError: android.os.Bundle.getString Other methods like game.word.word
My game units have an angle variable, and a targetAngle variable. These variables range
My game is a small shooting game in cocos2d. The enemy generates the bullets
The game I'm developing renders perfectly on the Java backend and on IE 10.
Permutation Game (30 Points) Alice and Bob play the following game: 1) They choose

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.