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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:06:32+00:00 2026-06-12T20:06:32+00:00

I have a table view with only one cell. When I call a method,

  • 0

I have a table view with only one cell. When I call a method, I try to refresh it and the text label’s text should change. However it does not, it only changes if the view re appears.

I have added NSLog() in many places and the correct methods and conditions are called

I have tried a few things:

reloadData
setNeedsDisplay
setNeedsLayout
reloadCell
reloadRowsAtIndexPaths: withRowAnimation:

But nothing has worked, I know it is not a problem with my UITableViewDataSource code because it is properly getting called.

This is the most appropriate code I can give you:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    tableView.scrollEnabled = NO;

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: @"cell"];

    if (cell) {

        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        if ([[TravelLogViewController locationArray] count]) {

            NSDictionary *flight = [NSDictionary dictionaryWithObjectsAndKeys:[[TravelLogViewController locationArray] lastObject], @"name", [[TravelLogViewController dateArray] lastObject], @"date", [[TravelLogViewController milesGainedIndex] lastObject], @"miles", nil];

            cell.detailTextLabel.textColor = [UIColor blackColor];

            cell.textLabel.numberOfLines = 2;
            cell.detailTextLabel.numberOfLines = 2;

            cell.textLabel.font = [UIFont fontWithName:@"Avenir" size: 14.0];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Avenir" size: 12.0];

            cell.selectionStyle = UITableViewCellSelectionStyleNone;

            cell.textLabel.text = [flight objectForKey: @"name"];

            cell.detailTextLabel.text = [NSString stringWithFormat:@"Flight Date: %@, Miles Gained: %.1f", [flight objectForKey: @"date"], [[flight objectForKey: @"miles"] doubleValue]];

            cell.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1];
            //        cell.backgroundColor = [UIColor clearColor];
        }
        else {

// This gets called when I want it to, but the textLabel text or detailTextLabel text is not changed


            cell.detailTextLabel.text = nil;
            cell.textLabel.text = nil;
            cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size: 18.0];
            cell.textLabel.text = @"\n\n                 No Flights";
        }
    }

    return cell;
}

UPDATE:

I am using ARC, and I have found that the table view is nil at the time I try to update the cell, but I have revised my cell and have no clue why!?

I am not nilling or releasing my table view anywhere, it should still be allocated

By the way I have a tab bar controller

UPDATE:

I have started a bounty now, its over a week later and I really feel this question needs some more attention and answers, I have checked my code multiple times and I cannot see why the table view is not updating / is nil.

UPDATE:

Ok, I have forgot to mention that the user can swipe to delete the cell. When he does, it does not actually delete the cell, it just changes its text (that is the part it is not updating). I put logs in viewDidLoad and viewDidAppear and table view appears to be valid, once the user swipes to delete… here is my code:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if (editingStyle == UITableViewCellEditingStyleDelete) {

    TravelLogViewController *travel = [[TravelLogViewController alloc] init];
    [travel manuallyDeleteTopCellData]; // Deletes some data in other view controller and calls the method `proceedWithDeletion`
}
}
- (void)proceedWithDeletion {

// Method is called from another view controller

NSLog(@"%@", mostRecentFlight.description); // NIL HERE

[mostRecentFlight reloadData];
[mostRecentFlight setNeedsDisplay];
[mostRecentFlight setNeedsLayout];

}

TravelLogViewController

- (void)manuallyDeleteTopCell {

[TheMileIndexViewController deductDesiredMilesToIndex: [[milesGainedIndex lastObject] floatValue]];

[locationArray removeLastObject];

[milesGainedIndex removeLastObject];

[dateArray removeLastObject];

MenuMileIndexViewController *menu = [[MenuMileIndexViewController alloc] init];
[menu proceedWithDeletion];

}

So to sum up, one the view loads/appears, the table view is valid. When the user swipes to delete, it does not actually delete the row it just calls another view controller called TravelLogViewController method called manuallyDeleteTopCellData where it deletes some data, that method then calls another method in my original view controller called proceedWithDeletion where it is supposed to reload the table view, but doesn’t (the problem). The reason for this is because in proceedWithDeletion the table view is nil, but why!?

  • 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-12T20:06:34+00:00Added an answer on June 12, 2026 at 8:06 pm

    This code could be the source of your problem:

    MenuMileIndexViewController *menu = [[MenuMileIndexViewController alloc] init];
    [menu proceedWithDeletion];
    

    You’re creating a brand new MenuMileIndexViewController, not accessing the already existing instance, which is what I presume you want to do. This new instance won’t have access to the original table view stored in mostRecentFlight. Inside -manuallyDeleteTopCell, you’ll need a reference to the calling MenuMileIndexViewController instance.

    It might be as simple as passing self to -manuallyDeleteTopCellData and using that variable to subsequently call -proceedWithDeletion on. For example:

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            TravelLogViewController *travel = [[TravelLogViewController alloc] init];
            [travel manuallyDeleteTopCellData:self];
        }
    }
    
    - (void)manuallyDeleteTopCell:(id)sender {
        [TheMileIndexViewController deductDesiredMilesToIndex: [[milesGainedIndex lastObject] floatValue]];
        [locationArray removeLastObject];
        [milesGainedIndex removeLastObject];
        [dateArray removeLastObject];
        // MenuMileIndexViewController *menu = [[MenuMileIndexViewController alloc] init];
        [sender proceedWithDeletion];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table view of peoples names and when I click on one
I have a table view with numerous cells. When I press one, a tick
I have a table view controller with (among others) a cell that is to
I have a table view with a custom cell ( UISwitch on every cell
I have a Table View Controller with cells. I want to update the text
I have a Nib file containing grouped table view and a cell. The cell
i have a table view. And im adding two buttons to each cell: -
Actually I have 4 view attached to a single view, only one view is
I have a table view with multiple sections and don't know how to change
I have a table view project with multiple controllers and another one that is

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.