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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:41+00:00 2026-06-13T17:23:41+00:00

I am struggling with a UITableView that I previously had working and somehow I

  • 0

I am struggling with a UITableView that I previously had working and somehow I have broken it!
It is part of a unit in Paul Hegarty’s course

The symptom is that the view loads but it is empty. I am clearly misunderstanding something fairly basic.

So far as I understand the two key methods are 1 the section rows count which in my case is returning zero, which I know is wrong!

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section


 {


 //   #warning Incomplete method implementation.
    // Return the number of rows in the section.
    NSLog(@"TopPlaces %@",self.topPlaces);
    //return 100;
    return [self.topPlaces count];

   }

Because of the above the following method is never called because there are no rows.

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

And the second is within ViewDidLoad where I can log my data to the console and everything appears fine. i.e. my data is generated within ViewDidLoad

- (void)viewDidLoad


 {
        [super viewDidLoad];

    dispatch_queue_t    dowloadQueue = dispatch_queue_create("flick downloader", NULL);
    dispatch_async(dowloadQueue, ^{
        NSArray *topPlaces = [FlickrFetcher topPlaces];
        //NSLog(@"Array is %@",topPlaces); // array is OK here
        dispatch_async(dispatch_get_main_queue(), ^{
            NSSortDescriptor *woeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"_content" ascending:YES];  
            NSArray *woeDescriptors = @[woeDescriptor];
            NSArray *sortedReturns = [topPlaces sortedArrayUsingDescriptors:woeDescriptors];
            self.topPlaces = sortedReturns;
            //all the data is present here, count is 100 and array will log to console
           NSLog(@"count here is %u",[self.topPlaces count]);
        });
    });

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

}
  • 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-13T17:23:42+00:00Added an answer on June 13, 2026 at 5:23 pm

    The problem is that you make an asynchronous call to fetch the data (which means that your array should be full of data at some point in the future), but you do not reload your tableview afterwards. Calling reloadData will do the trick:

     ...            
    self.topPlaces = sortedReturns;
    //all the data is present here, count is 100 and array will log to console
    NSLog(@"count here is %u",[self.topPlaces count]);
    
    [self.tableView reloadData]; // Assuming that 'tableView' is your outlet
    

    This will instruct your tableview to query once again its datasource and will eventually load all the data in your (now non-empty) topPlaces array.


    Further Explanation:

    I saw in the comment of @nerak99 that he is not completely sure why the problem fixed with reloadData.
    Well, let’s use an example:

    Imagine that you’ve got a restaurant.

    You open the place at 06:00 in the morning and you see that you’ve got nothing to cook. So you ask from one of your guys to go to the market for supplies (that’s your asynchronous call).

    At the same time you instruct a waitress to write today’s menu, so she writes… well, nothing (that’s your tableview asking for number of rows).

    Now at 07:00 the guy who went to the market returns with 10 items. What is the next logical step in order to update your menu? To actually inform the waitress (that’s your reloadData) about the items you’ve returned with.

    I hope that this makes sense 🙂

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

Sidebar

Related Questions

I have a UITableView that is broken up into a user defined number of
Struggling with the following problem. I have an attribute that defines the name of
Struggling a bit today. I have the following method that returns a list of
Struggling with command line again, I have figure out that I can store the
Struggling with styling the mouse over for a button ... I have managed to
Im struggling with this one. I have a list of items and on a
Iam struggling with NHibernate and its lazyload. I have a structure which I simplified
been struggling with an issue now for a day or two. I have an
I have a UITableView which is populated with an array of objects of type
Struggling with CSS selector. Want to select all FORM elements that are ancestors of

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.