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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:02:16+00:00 2026-05-31T19:02:16+00:00

I am working on my first Objective-C app for iOS and am having an

  • 0

I am working on my first Objective-C app for iOS and am having an issue with reloading the data in a UITableView.

After reloading the data the cell content will only update when the cell is scrolled above of below the viewable area of the container.

Here is my .h code:

#import <UIKit/UIKit.h>
#import "AFHTTPClient.h"
#import "AFJSONRequestOperation.h"

@interface HelloWorldViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>{
    NSMutableArray *tableViewArray;
    IBOutlet UITableView *tableView;
}
@property (nonatomic, retain) NSMutableArray *tableViewArray;
@property (weak, nonatomic) IBOutlet UILabel *connectionLabel;
@property (nonatomic, retain) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UITextView *textArea;
@property (weak, nonatomic) IBOutlet UITextField *textField2;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (copy, nonatomic) NSString *userName;
@property (copy, nonatomic) NSString *passWord;
@property (copy, nonatomic) NSMutableString *serverResponse;
- (IBAction)callHome:(id)sender;
@end

and .m code:

#import "HelloWorldViewController.h"

@interface HelloWorldViewController ()

@end

@implementation HelloWorldViewController
@synthesize tableViewArray;
@synthesize connectionLabel;
@synthesize userName = _userName;
@synthesize passWord = _password;
@synthesize serverResponse = _serverResponse;
@synthesize tableView;
@synthesize textArea;
@synthesize textField2;
@synthesize label;
@synthesize textField;

- (void)viewDidLoad
{
    [super viewDidLoad];
    tableViewArray = [[NSMutableArray alloc] init];
    [tableViewArray addObject:@"TEST1"];
    [tableViewArray addObject:@"TEST2"];
    [tableViewArray addObject:@"TEST3"];
}

- (void)viewDidUnload
{
    [self setTextField:nil];
    [self setLabel:nil];
    [self setTextField2:nil];
    [self setTextArea:nil];
    [self setTableView:nil];
    [self setConnectionLabel:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    if (theTextField == self.textField) {
        [theTextField resignFirstResponder];
    }
    return YES;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [tableViewArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    cell.textLabel.text = [self.tableViewArray objectAtIndex: [indexPath row]];
    return cell;
}

- (IBAction)callHome:(id)sender {
    self.userName = self.textField.text;
    self.passWord = self.textField2.text;

    NSMutableString *tempResponse = [[NSMutableString alloc] initWithFormat:@""]; 

    AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://example.com/"]];

    [client  setAuthorizationHeaderWithUsername:self.userName password:self.passWord];

    [client getPath:@"login.do" parameters:nil 
            success:^( AFHTTPRequestOperation *operation , id responseObject ){
                NSLog(@"Authentication Success: %d", operation.response.statusCode); 
                self.serverResponse = [NSMutableString stringWithFormat:@"Authentication Success: %d", operation.response.statusCode ]; 
                [tempResponse appendString: self.serverResponse];
                self.textArea.text = tempResponse;
            } 
            failure:^(AFHTTPRequestOperation *operation , NSError *error){
                NSLog(@"Authentication Error: %@\n%@", error, operation);
            }
     ];

    [client getPath:@"test.json.do" parameters:nil 
            success:^( AFHTTPRequestOperation *operation , id responseObject ){
                NSLog(@"Retrieval Success: %d", operation.response.statusCode);
                NSDictionary *results = [operation.responseString JSONValue];
                NSMutableArray *buildings = [results objectForKey:@"buildings"]; 
                NSMutableArray *names = [[NSMutableArray alloc] init]; 
                for (NSDictionary *building in buildings)
                {
                    [names addObject:[building objectForKey:@"name"]];
                }
                self.tableViewArray = names;
                self.serverResponse = [NSMutableString stringWithFormat:@"\nBuilding List Retrieval Success: %d", operation.response.statusCode ]; 
                [tempResponse appendString: self.serverResponse];
                self.connectionLabel.text = tempResponse;
            } 
            failure:^(AFHTTPRequestOperation *operation , NSError *error){
                NSLog(@"Retrieval Error: %@\n%@", error, operation);
            }
     ];

    NSLog(@"tableView is: %@", [tableView description]);
    [tableView reloadData];
}

@end

When I call [self.tableView description]the result is null, but if I call it from cellForRowAtIndexPath then I get the following result:

tableView is: <UITableView: 0x8a71000; frame = (0 0; 280 191); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x6b7e860>; contentOffset: {0, 0}>. Delegate: HelloWorldViewController, DataSource: HelloWorldViewController

Here’s a screenshot of interface builder:
enter image description here

All help is appreciated! Thanks!

  • 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-31T19:02:17+00:00Added an answer on May 31, 2026 at 7:02 pm

    You’re probably not connecting the UITableView in the interface builder..

    You have to drag while pressing ctrl from the file’s owner to the UITableView and connect it.

    Also, you should not access your properties without self, you should do:

    @synthesize tableViewArray = _tableViewArray;
    

    and then access it with:

    self.tableViewArray
    

    try to avoid accessing your ivars directly, use the property!

    Good luck!

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

Sidebar

Related Questions

I'm working on my first somewhat serious iOS app and I'm new to Xcode,
I'm working on my first Core Data project (on iPhone) and am really liking
I am in the process of building my first iPhone app (xCode,objective-c) which has
I've been working on my first XCode/iOS project and so far it's been an
This is my first time working with Objective-C, and I keep trying to create
I'm working on my first JSON example in objective-c and came across this great
I'm working on an iOS app and have had some trouble with getting photos
I'm new to Objective C and XCode, currently working on my first iPhone Game.
I am working on an iPhone app that will construct, at run-time, an NSMutableDictionary
I'm working on my first ever cocoa/Objective-C application, so please bear with me if

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.