title: iOS Reload Table Methods
body: <p>I have a tab bar, the first view requires a login alertview and that works fine. When I switch to the next tab, I have a table view.</p>
  
  <p>i am fetching data from online using JSON in a method which I call from the viewDidLoad method in a table view controller along with another login procedure. I want two sections and the data in each section depends on one of the properties I get from parsing the data.</p>
  
  <p>The problem is that by the time the data is parsed, the table view methods would already be finished so I get 0 section and 0 rows and no data displaying. 
  So my question is, is there a way to just reload the no of sections method, no of rows method and the cellForRowAtIndexPath method. If i reload the entire table view, I get infinite alertviews asking for login :/</p>
  
  <p>EDIT:</p>
  
  <pre><code>     #import "BooksViewController.h"
       #import "Me.h"
       #import "SBJson.h"
  
       @interface BooksViewController ()
  
       @end
  
       @implementation BooksViewController
  
       @synthesize name = _name;
       @synthesize ID = _id;
       @synthesize extended = _extended;
       @synthesize returned = _returned;
       @synthesize Date = _date;
  
       -(void) dealloc
       {
           self.name = nil;
           self.ID = nil;
           self.extended = nil;
           self.returned = nil;
           [super dealloc];
       }
  
       - (id)initWithStyle:(UITableViewStyle)style
       {
           self = [super initWithStyle:style];
           if (self) {
  
               BooksBorrowed = [[NSMutableArray alloc]init];
               BorrowedDates = [[NSMutableArray alloc]init];
               BorrowedIDs = [[NSMutableArray alloc]init];
               BorrowedExtensions = [[NSMutableArray alloc]init];
               BorrowedReturns = [[NSMutableArray alloc]init];
  
               /*message = [[UIAlertView alloc] initWithTitle:@"Please Login with your User                            ID and Password"
                message:nil
                delegate:self
                cancelButtonTitle:@"Cancel"
                otherButtonTitles:@"Continue", nil];
  
                [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];*/
               //book = [[BooksViewController alloc]init];
               me = [[Me alloc]init];
           }
           return self;
       }
  
       - (void)MyBooks
       {
  NSString *authFormatString =
  @"http://localhost:8888/Jineel_lib/bookBorrowed.php?uid=%d";
  
  NSString *urlString = [NSString stringWithFormat:authFormatString, 1];
  
  NSURL *url = [NSURL URLWithString:urlString];
  
  NSString *contents = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
  
  response1 = [contents JSONValue];
  if(contents)
  {
      NSLog(@"contents : %@",contents);
      BookName = [[NSString alloc]init];
      DateBorrowed = [[NSString alloc]init];
      BookID = [[NSString alloc]init];
      BookExtended = [[NSString alloc]init];
      BookReturned = [[NSString alloc]init];
  
      BookName = [response1 valueForKey:@"BookName"];
      BookID = [response1 valueForKey:@"BookID"];
      DateBorrowed = [response1 valueForKey:@"DateBorrowed"];
      BookExtended = [response1 valueForKey:@"Extended"];
      BookReturned = [response1 valueForKey:@"Returned"];
  
      [BooksBorrowed addObject:BookName];
      [BorrowedDates addObject:DateBorrowed];
      [BorrowedIDs addObject:BookID];
      [BorrowedReturns addObject:BookReturned];
      [BorrowedExtensions addObject:BookExtended];
  
      NSLog(@"Arrays are : %@, %@, %@, %@, %@", BooksBorrowed, BorrowedDates, BorrowedIDs, BorrowedReturns, BorrowedExtensions);
           }
       }
  
  
       - (void)viewDidLoad
       {
           [super viewDidLoad];
  
           // 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;
           [self MyBooks];
       }
  
       - (void)didReceiveMemoryWarning
       {
  [sup         er didReceiveMemoryWarning];
           // Dispose of any resources that can be recreated.
       }
  
       #pragma mark - Table view data source
  
       - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
       {
           // Return the number of sections.
           return 1;
       }
  
       - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(         (NSInteger)section
       {
           // Return the number of rows in the section.
           NSLog(@"rows %d", [BooksBorrowed count]);
           return [BooksBorrowed count];
       }
  
       - (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] autorelease];
           }
  
                    bookName = BooksBorrowed[0];
  
                    cell.textLabel.text = bookName;
                    return cell;
       }
  
       @end
  </code></pre>