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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:26:44+00:00 2026-06-18T14:26:44+00:00

Im doing a tic tac toe game in xcode. this is my code –

  • 0

Im doing a tic tac toe game in xcode. this is my code

    - (IBAction)c1Button:(id)sender {
if ((status.text = @"X goes now"))
{
    c1.text = @"X";
    if ([c1.text isEqualToString: @"X"])
    {
        status.text = @"O goes now";
    }
    else
    {
        status.text = @"X goes now";
    }
}
else if ((status.text = @"O goes now"))
{
    c1.text = @"O";
    if ((c1.text = @"O"))
    {
        status.text = @"X goes now";
    }
    else
    {
        status.text = @"O goes now";
    }
}
}

When the first cell is clicked a X appears as it should. And the status label changes to O goes now. But the when the cell is clicked it still writes X instead of O. What is wrong?

  • 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-18T14:26:45+00:00Added an answer on June 18, 2026 at 2:26 pm

    In the first if statement you assign as string instead of comparing it. This:

    if ((status.text = @"X goes now"))
    

    should be:

    if ([status.text isEqualToString:@"X goes now"])
    

    And the same goes for the second statement.

    Also, it is a better idea to keep the state (as an integer or boolean) and not use the title to resolve the state each time.

    #define X_TURN    0
    #define O_TURN    1
    
    
    // ....
    
    if (turn == X_TURN)
    {
        c1.text = @"X";
        status.text = @"O goes now";
        turn = O_TURN;
    }
    else
    {
        c1.text = @"O";
        status.text = @"X goes now";
        turn = X_TURN;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a tic tac toe game and I am trying to add a
I have this first integration test for a tic tac toe game: [TestClass] public
I'm writing a basic tic tac toe game in Java. In my Board class
Let's say I'm trying to write a simple Tic-Tac-Toe game. It has an M
I am writing a tic-tac-toe game in Java. I have a 2D array representing
I am programming a javascript based tic tac toe game. I want to make
I'm making a Tic-tac-toe game and i have a board class which contains 9
I have built a two-player tic tac toe game in Java, using sockets (no
I'm writing a Tic Tac Toe Game and I would like to know how
I'm trying to program a multiplayer tic-tac-toe game in VBScript/ASP. Microsoft VBScript compilation error

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.