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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:37:00+00:00 2026-06-04T21:37:00+00:00

I have setup an if statement in a method to setup questions (labels) in

  • 0

I have setup an if statement in a method to setup questions (labels) in a tab view controller. The code is taking data from a xml file and the current tab view title to setup the questions. While debugging the fist time the code is run it gives me “Page 1” == “Page 1” and preforms the operations, but when I select another view controller on the tab bar I get “Page 2” == “Page 2” while debugging, but it does not do the logic with the if statement. If I make it if(1){logic} it does the logic both times, but does not separate my questions into page 1 and page 2. The view and view names are created dynamically using the information from the same xml file, so there is no chance of misspelling.

Here is the code in question. Any help would be nice as I have a headache after hours of trying thinks and searching online trying to figure out why a true if statement is not working the second time through the code.

//setup questions at runtime  --not working--

-(void)setupQuestions{

    int lableY = 85;

    NSString *pageTital = self.pageTabViewLable.title;
    NSString *questionPage;


    for (int i = 0; i < self.question_array.count; i++) {

        self.currentQuestion = [self.question_array objectAtIndex:i];  //Get information of current Question from array

        questionPage = self.currentQuestion.Page;

        if (pageTital == questionPage){

            //Create a Dynamic Label for Question.
            UILabel *lablel;
            CGRect lableFrame = {155,lableY,600,25};
            lablel = [[UILabel alloc] initWithFrame:lableFrame];
            lablel.text = self.currentQuestion.Question;
            [self.view addSubview:lablel];
            lableY += 90;               //lable spacing

        }
    }
} 




//at runtime setup tabs  --working--

-(void)setupTabPages{



    NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];  //Create a array to hold tab veiws

    if( newArray.count != self.totalTabPageCount)  //check to see is amount of veiws and cussrent reated views are the same
    {

       self.pageTabViewLable.title = [xmlParser1 getPageWithIndexLocation:0];  //set text of inital view

        UIStoryboard *storyboard = self.storyboard; //get storyboard context information from view name

        if (self.totalTabPageCount != -1) {     //check for xml error

            for (int i = 1; i < self.totalTabPageCount; i++) {  //create additional views from storyboard view
                Check_StratusViewController *cvc = [storyboard instantiateViewControllerWithIdentifier:@"Check_StratusViewController1"];
                cvc.pageTabViewLable.title = [xmlParser1 getPageWithIndexLocation:i];
                [newArray addObject:cvc];


            }

            [self.tabBarController setViewControllers:newArray animated:YES];  //add the views
        } 

    }

    self.totalQuestionCount = [xmlParser1 getTotalQuestionCount];

    self.currentQuestion = [[Question alloc] init];
    self.question_array = [[NSMutableArray alloc] init];

    for (int i = 0; i < self.totalQuestionCount; i++) {
        [self.question_array addObject:[xmlParser1 getQuestionAtIndelLocation:i]];
    }


    [self setupQuestions];


}
  • 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-04T21:37:01+00:00Added an answer on June 4, 2026 at 9:37 pm

    You shouldn’t use pageTital == questionPage to compare 2 strings, you should use [pageTital isEqualToString questionPage]

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

Sidebar

Related Questions

I have my controller Setup my join_model and my login_model A user registers and
I am wondering which is a more efficent method to retrieve data from the
We have a static method in a utility class that will download a file
I have setup a test database and console app to confirm the following: Given
I have read these very good questions on SO about SQL stored procedures: When
I have the following jQuery ajax call setup: function Testing() { var result =
I have a custom UITableViewCell class, and within that I've overridden the drawRect method
I have set up a UITableView with 3 sections that pulls from 3 NSArrays
I have a view with a custom slider. We are using a subclass of
i have questions regarding the shake detection that posted here before, here is a

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.