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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:09:37+00:00 2026-06-16T04:09:37+00:00

I am using Xcode creating an iOS app. I am also using a SQL

  • 0

I am using Xcode creating an iOS app. I am also using a SQL server (xampp). It works good overall. But I have problem at the following point:

-I have view controller with a Table View and I am populating this table using the result of the SQL query (imagine taglist is an array containing 12 rows)

- (void)viewDidLoad

[[API sharedInstance] commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"listtags", @"command", nil] onCompletion:^(NSDictionary *json) {

    NSArray* result = [[NSArray alloc] initWithArray:[json objectForKey:@"result"]];
    taglist =[[NSMutableArray alloc] initWithArray:result];
    [taglist removeAllObjects];
    for(NSDictionary* i in result){
        [taglist addObject:[i objectForKey:@"tag"]];
    }
    NSLog(@"sql %u",taglist.count);
}];

NSLog(@"did load %u",taglist.count);

}

And there are two required methods for tableviews

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

NSLog(@"table %u",taglist.count);
return taglist.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];


NSLog(@"cell %u",taglist.count);
cell.textLabel.text = [taglist objectAtIndex:indexPath.row];

return cell;

}

The problem is since it takes a while to get the query result, my table methods use the empty taglist array to populate. The output of the NSLogs are like this

2012-12-19 14:35:41.470 iReporter[33507:c07] did load 0
2012-12-19 14:35:41.473 iReporter[33507:c07] table 0
2012-12-19 14:35:41.476 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.479 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.481 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.483 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.484 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.486 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.487 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.489 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.493 iReporter[33507:c07] cell 0
2012-12-19 14:35:41.564 iReporter[33507:c07] sql 12

Which means the taglist array is empty after the viewDidload , numberofRows and cellForRow functions. But when the query is completed I can get the correct value. But by then my table properties are already defined so it is no use,
My question is , is there a way to wait for that response and after making sure that it is not empty then to use it to create the table.
Thank you

  • 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-16T04:09:39+00:00Added an answer on June 16, 2026 at 4:09 am

    After you get the results from your query and you update taglist, call [self.tableView reloadData].

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

Sidebar

Related Questions

I am creating an iPad app using XCode 4 and Storyboards. I have a
I'm creating an iphone app using xcode 4.2, and trying to use the AVFoundation
Good day! I am using Xcode 3.1.4 and iPhone SDK 2.2.1. I am creating
I'm creating a project in Java using XCode 3.2.1..... But it is giving an
I am currently creating an iPhone app using Xcode 4.0.2, I want the app
I've been tasked with creating an IM app for IOS. I currently have an
I am little bit confused about creating universal application for iOS devices using Xcode
I am new to iOS, i am using Xcode 4.3.2, and i have created
I am creating an iPad app using the master-detail template available in Xcode 4.3.
I am learning iOS. I m using Xcode 4.3.2 , and i have created

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.