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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:30:45+00:00 2026-06-17T12:30:45+00:00

Im creating a Sectioned tableView and I need to set titles programmatically.But the titles

  • 0

Im creating a Sectioned tableView and I need to set titles programmatically.But the titles are not static.I want to display date and day which are again not static as title for a particular section.I have both of them stored in NSString.

In one context like for one company I have to display like this :

1/12/2013 Saturday                        //section 0
13:00hrs  14:00hrs  15:00hrs

1/13/2013 Sunday                          //section 1
14:00hrs  15:00 hrs

For another company I have to display like this:

1/15/2013 Tuesday                        //section 0
13:00hrs  14:00hrs  15:00hrs

1/16/2013 Wednesday                      //section 1
14:00hrs  15:00 hrs

1/17/2013 Thursday                       //section 2
14:00hrs  15:00 hrs

Like this but here I dont have static number of companies and static dates and days.
Im checking for a particular condition and displaying in sections for particular dates and days.And I have to set title as date and day of that section.

How can I do it?

The calculation of date and day goes like this:

-(void)LoadData
{

for(int i=0;i<5;i++)
    {

        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

        NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
        [offsetComponents setDay:i];
        NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate: [NSDate date]options:0];
        [offsetComponents release];
        [gregorian release];


        NSDateFormatter *formatterforGridSectionDate=[[[NSDateFormatter alloc]init] autorelease];
         formatterforGridSectionDate.dateFormat = @"MM/dd/yyyy";
        getDateinGridSection=[[NSString stringWithFormat:@"%@",[formatterforGridSectionDate stringFromDate:nextDate]] componentsSeparatedByString:@""];
        gridSectionDate=[[getDateinGridSection valueForKey:@"description"] componentsJoinedByString:@""];
        NSLog(@"%@",gridSectionDate); // Here I get date in MM/dd/yyyy format 
        weekdayString=[nextDate descriptionWithCalendarFormat:@"%A" timeZone:nil locale:[[NSUserDefaults standardUserDefaults]dictionaryRepresentation]];
        NSLog(@"Day :%@",weekdayString);
        [self check];


    }
      //creating a tableView 


}

-(void)check
{
 //calling the service url for the particular day and date and store the values in array
        NSLog(@"%@",array);

        if([array count]>0)
       {
          [tblViewarray addObject:array];

       }
}

How can I get the date and day as title for which section is loaded in tableview?

  • 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-17T12:30:45+00:00Added an answer on June 17, 2026 at 12:30 pm

    UPDATE:

    Here your requirement is display the date with day name on every section of UITableView.

    You have array of Dates for example with name yourDateArray, here i create code for how to display that date on every section with your required date format.

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        return [yourDateArray count];
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    
    
        NSString *str = [yourDateArray objectAtIndex:section];
    
        NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
        [dateFormatter setDateFormat:@"MM/dd/yyyy"];
    
        NSDate *date = [dateFormatter dateFromString: str];
    
        dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
        [dateFormatter setDateFormat:@"MM/dd/yyyy EEEE"];
    
        NSString *convertedString = [dateFormatter stringFromDate:date];
        NSLog(@"Converted String : %@",convertedString);
    
        return convertedString;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iPhone I am creating an application which display the name
When creating an NSFetchedResultsController instance, there is this sectionNameKeyPath: argument, which most peoeple seem
I am creating a section view programmatically and I have a UIButton delete also
I am currently in the process of creating a sectioned listview. So far I've
I'm having difficulties creating a query to pull a certain result set from a
i want to create an application in one row of tableView there will be
I am creating grouped table in my application. It works fine. But when I
I add header and footer view while creating my table. What I want to
I am currently creating a TableView application using sqlite and thus far, it works
I am creating a button pro-grammatically in my TableView Header cell and adding TouchUpInside

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.