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

  • Home
  • SEARCH
  • 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 6786511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:15:15+00:00 2026-05-26T17:15:15+00:00

Want to populate two NSMutableArray s to 2 Custom Sections of tableView ; I

  • 0

Want to populate two NSMutableArrays to 2 Custom Sections of tableView;

I have two NSMutableArrays with events and I want to split them to now and today sections.

For the first section:

I want to remove events from nowEvents Array and place them into my frist section.

EventClass *event = [appDelegate.nowEvents objectAtIndex:indexPath.row];

event.startTime is the start time of my event

event.endTime is the end time of my event

For 2nd section:
Remove the events that are happening now

EventClass *event = [appDelegate.todayEvents objectAtIndex:indexPath.row];

What I’d like to know is numberOfRowsInSection method, how it would look like and cellForRowAtIndexPath (here I’ve tried NSInteger section = [indexPath section]; if (section == 0) { } if (section == 1) {} – but what about if I won’t have an event that is happening now ?)

  • 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-05-26T17:15:16+00:00Added an answer on May 26, 2026 at 5:15 pm

    Something like this should work

    #pragma mark - Table view data source
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.
        // Return the number of rows in the section.
        switch (section) {
            case 0:
                return [appDelegate.nowEvents count];
            case 1:
                return [appDelegate.todayEvents count];    
            default:
                return 0;
        }
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    
    
        switch (indexPath.section) {
            case 0:
                EventClass *nowEvent = [appDelegate.nowEvents objectAtIndex:indexPath.row];
                //set up cell to display this event
                break;
            case 1:
                EventClass *todayEvent = [appDelegate.todayEvents objectAtIndex:indexPath.row];
                //set up cell to display this event
                break;    
            default:
                break;
        }
    
        // Configure the cell...
    
        return cell;
    }
    

    If you don’t have an event happening now then your nowEvent array will be empty so in the numberOfRowsInSection will return 0 and therefore the cellForRowAtIndexPath won’t be called as there is nothing to display. Hope this helps.

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

Sidebar

Related Questions

I have two databases: Transactions and Customer List I want to populate the customer
I have nested containers std::map<int, std::map<T, U> > and want to populate them properly,
I have two select controls that I want to populate with the exact same
I have two dropdowns. I want to populate the second dropdown on selection of
I have an ExpandableListView that I want to populate with my custom views of
I have a sort of unique situation....I want to populate a ModelChoiceField based of
I have an xml data file and I want to populate a listview in
I have two dates fields for fromdate and todate Based on that i want
I have the following code, which works fine if you just want to populate
In a webpart I have two user controls loaded. I want to be able

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.