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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:10:34+00:00 2026-05-25T16:10:34+00:00

Just trying to understand my table isn’t being populated when my view controller appears

  • 0

Just trying to understand my table isn’t being populated when my view controller appears here. I’m using AIHTTPRequest to communicated with a REST API. The call returns an array of associative arrays (which I’m assuming I’ll have to cast to an NSArray of NSDictionaries).

In the header of my TableViewController:

@interface MyTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    NSArray *homepageItems;
}

@property (nonatomic, retain) NSArray * homepageItems;

In the implementation:

@synthesize homepageItems;
....
- (void)viewDidLoad {

NSURL *url = [NSURL URLWithString:URL_TO_MY_API];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];

When the data is returned:

- (void)requestFinished:(ASIHTTPRequest *)request
{
    // Use when fetching text data
    NSString *responseString = [request responseString];
    id response = [responseString objectFromJSONString];
    homepageItems = (NSArray *)response;
}

And in the Table View method:

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
    }

    NSDictionary *dataItem = [homepageItems objectAtIndex:indexPath.row];

    // Configure the cell...
    cell.textLabel.text = [dataItem objectForKey:@"message"];

    return cell;
}

When the view loads nothing is in the table. I suspect this is happening because when the table view method is fired homepageItems hasn’t been populated by the asynchronous method. How can I achieve the data being loaded into the table view?

Thanks,

EDIT: In my requestFinished method, I’ve examined the homepageItems object by doing the following:

for(NSDictionary *dictionary in homepageMMDs) {
    NSLog(@"%@", [dictionary objectForKey:@"message"]);
}

And the proper messages from my API service are being logged.

  • 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-25T16:10:35+00:00Added an answer on May 25, 2026 at 4:10 pm

    You are not retaining the downloaded data:

    Instead of:

    - (void)requestFinished:(ASIHTTPRequest *)request
    {
        // Use when fetching text data.
        NSString *responseString = [request responseString];
        id response = [responseString objectFromJSONString];
        homepageItems = (NSArray *)response;
    }
    

    You need to do: (crucially using self in front of homepageItems)

    - (void)requestFinished:(ASIHTTPRequest *)request
    {
        // Use when fetching text data.
        NSString *responseString = [request responseString];
        id response = [responseString objectFromJSONString];
        self.homepageItems = (NSArray *)response; 
        // and others have said you need to reload the tableView
        [self.tableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just trying to understand delegates using the following code. public class delegatesEx
Just trying to understand the linear probing logic. With as hashtable using open addressing,
Just trying to understand that - I have never used it before. How is
I am just trying to understand the extends keyword in Java Generics. List<? extends
I grabbed this code form JCarousel and just trying to understand these lines below.
I've been a visual studio developer for long and just trying to understand how
im just starting to learn flex and im trying to understand how Flex does
I'm just learning ruby and trying to understand the scope of code executed in
I just joined a new C++ software project and I'm trying to understand the
I've been trying for 3 hours and I just can't understand what is happening

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.