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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:31:27+00:00 2026-06-04T05:31:27+00:00

I’m trying to to call the [MyTableviewController.tableview reloaddata] function for my UITableView. I figured

  • 0

I’m trying to to call the [MyTableviewController.tableview reloaddata] function for my UITableView. I figured the best place to do so is the -(void) viewWillAppear method of the UITableViewController subclass.

The code somehow wasn’t created upon creating the class and i tried to implement the method with little success.

After some research on SO and various other Websites i found hints that the problem might be that the UIViewController subclass is part of an Navigation Controller, which is in turn part of an Tab Bar Controller. The general suggestion and code posted was to subclass one (which?) of the controllers and implement the -viewWillAppear message.

My questions are:
1. Is there a way to call this much needed method WITHOUT subclassing another controller?
2.If so, how do I do it?
3.If not, could you please explain to me exactly what i have to do and, more importantly, why i have to do it?

Heres the complete Code of the UITableViewController:

//
//  OverViewController.m
//  NoificationTest
//
//  Created by Mirko Winckel on 15.03.12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "OverViewController.h"
#import "SecondOverViewController.h"
#import "Globals.h"

@interface OverViewController ()

@end

@implementation OverViewController

@synthesize entrys;



- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        // Custom initialization
    }
    return self;
}



- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView reloadData];

    if (entrys == nil) 
    {

    NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString* fileName = [[Globals sharedGlobals].selectedProject stringByAppendingString:@".csv"];
    NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName];
    NSString* content = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:fileAtPath] encoding:NSUTF8StringEncoding];
    NSString *stringToFind =@"\n";
    entrys = [content componentsSeparatedByString:stringToFind];

    }


    /* Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;*/
}

- (void)viewDidUnload{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    int weeks = 1+1;

    return weeks;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

    NSString *sectionHeader = nil;

    if ( section == 0 ) {

       sectionHeader = @"Refresh - test";

    }

    if (  section == 1 ) {
        if ( [Globals sharedGlobals].selectedProject != nil){

            NSString* temp = @"Current in project ";
            [temp stringByAppendingString:[Globals sharedGlobals].selectedProject];

            sectionHeader = temp;

        }

        else {
            sectionHeader = @"No project selected";
        }
    }

    if (  section == 2 ) {
        sectionHeader = @"Week 3";
    }

    if (  section == 3 ) {
        sectionHeader = @"Week 4";
    }

    if (  section == 4 ) {
        sectionHeader = @"Week 5";
    }

    return sectionHeader;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int rows;

    if (section == 0){
        rows = 1;
    }

    if (section == 1 ){
        rows = [entrys count] -1;
    }



    return rows ;
}

- (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];
    }

    NSString *oneLine = [entrys objectAtIndex:indexPath.row];
    NSArray *lineComponents = [oneLine componentsSeparatedByString:@";"];

    cell.textLabel.text = [lineComponents objectAtIndex:0];
    cell.textLabel.textColor = [UIColor colorWithRed:0.0 green:0.8 blue:0.2 alpha:1.0];

    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

#pragma mark - Table view delegate



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{



    if (indexPath.section == 0) {

        [self.tableView reloadData];

        [tableView deselectRowAtIndexPath:indexPath animated:YES];



    }






    if (indexPath.section == 1) {

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    SecondOverViewController *anotherViewController = [[SecondOverViewController alloc] initWithStyle:UITableViewStylePlain];

    NSArray *rowArray = [[entrys objectAtIndex:indexPath.row] componentsSeparatedByString:@";"];

    anotherViewController.oneRow = rowArray;

    [self.navigationController pushViewController:anotherViewController animated:YES];

    } 





    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */

}

@end

Thanks in advance 🙂

  • 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-04T05:31:29+00:00Added an answer on June 4, 2026 at 5:31 am

    If your ViewController is derived from UITableViewController, try calling the reloadData function this way:

    [self.tableView reloadData];
    

    Also, I recommend calling reloadData under viewDidLoad instead of viewDidAppear. The latter can be called multiple times unexpectedly (for example when another view is popped off the stack), while the former is called just once.

    For example:

    - (void)viewDidLoad {
        [super viewDidLoad];
        [self.tableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.