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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:30:22+00:00 2026-05-30T09:30:22+00:00

first of all sorry if this isn’t formatted correctly, first time doing this. I’ve

  • 0

first of all sorry if this isn’t formatted correctly, first time doing this. I’ve been using stackoverflow to find help for a long time now and it’s been very helpful (thank you all), but this is the first time I’ve posted a question of my own. This question has been asked many times, but when I call [myTable reloadTable] the methods numberOfSectionsInTableView and numberOfRowsInSection are called but not cellForRowAtIndexPath.

Every answer I’ve seen when searching has been a variation of:
1) The tableView is nil
2) numberOfRowsInSection is 0
3) tableView’s delegate/data source not set
4) calling reloadTable on the wrong uiTableView.

None of these are the case for me so I’m wondering what else could be wrong.

What I’m trying to do:
I have a custom uitableviewcell with a button on it, when the button is pressed I want to change the attributes of the cell (for an example, let’s just say I want to change the cell title to “Button Pressed”). I then want to pause for a moment and then delete the cell.

Not sure if this is important, but my tableView is inside a UIViewController, and the viewController is the delegate and dataSource.

I have a method (below) that fires when the button is pressed and the cell attributes are changed as necessary, however when I try to refresh the table to show the changes it doesn’t work. The first time [remTable reloadData] is called, numberofsectionsintableview and numberofrowsinsection are called but not cellforrowatindexpath. However, the second time [remTable reloadData] is called all three methods are called and everything works correctly.

doneCell.remName.text=@"BUTTON PRESSED";
[remTable reloadData];
NSLog(@"sleep");
sleep(1);
[remList removeObject:doneReminder];
[remTable reloadData];

To test this I put nslog statements at the beginning of numberofsections, numberofrows and cellforrow, the output is the name of the method followed by the number (for numberofsections/numberofrows).

Output:

numberofsections 1
numberofrows 3
sleep
numberofsections 1
numberofrows 2
cellforrow

Any ideas as to why cellforrow’s not being called the first time? Thanks in advance, please let me know if there’s anything else I can add to clarify.

  • 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-30T09:30:24+00:00Added an answer on May 30, 2026 at 9:30 am

    A table view doesn’t actually request its cells until it needs to display them. When you call reloadData, it will immediately request the number of sections and rows so that it knows how big it needs to be. It doesn’t ask for the cells themselves until it is asked to display itself. Views are automatically displayed as necessary at the beginning of each run loop.

    Execution doesn’t return to the run loop until your code returns. When you call sleep, you don’t execute any code, but you also don’t return. This means the run loop doesn’t get a chance to display the table, so it never asks for any cells. What you need to do is return from your method and ask that another method gets called in 1 second to remove the doneReminder. An easy way to do this is to use the performSelector:withObject:afterDelay: method. This method adds a timer which will call the method you requested after the given delay, which means you can return to the run loop and let the table display.

    doneCell.remName.text=@"BUTTON PRESSED";
    [remTable reloadData];
    [self performSelector:@selector(removeDoneReminder) withObject:nil afterDelay:1.0];
    
    - (void)removeDoneReminder {
        [remList removeObject:doneReminder];
        [remTable reloadData];
    }
    

    If remlist and remTable are not instance variables, you can use the withObject: parameter to send them to the removeDoneReminder method.

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

Sidebar

Related Questions

First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
First of all, sorry if this has been asked before. I've done a pretty
First of all I'm sorry if you feel this question has been raised before,
Well, first of all sorry about this question it must be pretty straight forward
First of all, I'm fairly new to Java, so sorry if this question is
First of I'm very sorry but this questions is not so so specific. All
Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
first of all sorry by my bad english, Hello i am new in this
First of all Sorry for the really long post, now And this is my
First of all sorry, If somebody finds this question is repeated (haven't found any

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.