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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:23:59+00:00 2026-06-08T16:23:59+00:00

I have three strings and each one either says True or False. Depending on

  • 0

I have three strings and each one either says True or False. Depending on which strings say True I would display them in the table view. Here is the code I have:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  if ([appDelegate.showFirstField isEqualToString:@"True"]) {
    if (indexPath.section==2) {
        cell.textLabel.text=@"First Field Title";
    }
  }

  if ([appDelegate.showSecondField isEqualToString:@"True"]) {
    if (indexPath.section==3) {
        cell.textLabel.text=@"Second Field Title";
    }
  }

  if ([appDelegate.showThirdField isEqualToString:@"True"]) {
    if (indexPath.section==4) {
        cell.textLabel.text=@"Third Field Title";
    }
  }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
   //#warning Potentially incomplete method implementation.
   // Return the number of sections.
   int sectionNum = 2;
   if ([appDelegate.showFirstField isEqualToString:@"True"]) {
     sectionNum += 1;
   }
   if ([appDelegate.showSecondField isEqualToString:@"True"]) {
     sectionNum += 1;
   }
   if ([appDelegate.showThirdField isEqualToString:@"True"]) {
     sectionNum += 1;
   }
   return sectionNum;
}

The issue is that if showFirstField and showThirdField are True and showSecondField is False then the section title wont be set correctly. Is there a way I can set the title to the next available section.

  • 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-08T16:24:00+00:00Added an answer on June 8, 2026 at 4:24 pm

    After a couple hours working on it I took it from a different approach and this code works for me. set the check booleans to false and as global variables

    if ([appDelegate.showFirstField isEqualToString:@"True"] && checkFirst == FALSE){
        if (indexPath.section >1 && indexPath.section==indexPath.section) {
            checkFirst = TRUE;
            cell.textLabel.text=@"First Field Title";                
        }
    }
    else if ([appDelegate.showSecondField isEqualToString:@"True"] && checkSecond == FALSE){
        if (indexPath.section >1 && indexPath.section==indexPath.section) {
            checkSecond = TRUE;
            cell.textLabel.text=@"Second Field Title";
        }
    }
    else if ([appDelegate.showThirdField isEqualToString:@"True"] && checkThird == FALSE){
        if (indexPath.section >1 && indexPath.section==indexPath.section) {
            checkThirdField = TRUE;
            cell.textLabel.text=@"Third Field Title";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following three strings: (section1){stuff could be any character, i
I have a list of strings in kumo . I am printing three strings.
i have many urls(string): $one = 'http://www.site.com/first/1/two/2/three/3/number/342'; $two = '/first/1/two/2/number/32'; $three = 'site.com/first/1/three/3/number/7'; $four
Suppose I have a string like this: one two three four five six seven
I have two String arrays a,b. String a [] = {one,two,three}; String b []
I would like to create a UIView has multiple UITextFields validates each one as
I've been given some strings to work with. Each one represents a data set
I have three variables that may or may not contain data. let's call them
I have a method that returns one of about 20 possible strings from an
I have three models: class User include Mongoid::Document field :name, :type => String has_many

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.