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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:55:38+00:00 2026-06-12T17:55:38+00:00

Having issue with prefetching data and displaying on uitableview. So basically I want to

  • 0

Having issue with prefetching data and displaying on uitableview. So basically I want to block the main UI thread so that I can get data from web. I am using serial dispatch queue for synchronizing. Also, dispatch queue block is executing another block that fetches data from web. The code for executing is written in viewdidload:

dispatch_queue_t queue= dispatch_queue_create("myQueue", NULL);


CMStore *store = [CMStore defaultStore];

// Begin to fetch all of the items
dispatch_async(queue, ^{

[store allObjectsOfClass:[Inventory class]
       additionalOptions:nil
                callback:^(CMObjectFetchResponse *response) {

                    //block execution to fetch data

                }];
});
dispatch_async(queue, ^{
//load data on local data structure


    [self.tableView reloadData];
});
  • 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-12T17:55:39+00:00Added an answer on June 12, 2026 at 5:55 pm

    You should NEVER perform any UI-related code anywhere other than in the main thread/queue.

    Always perform every UI-related code (like reloadData on an UITableView) on the main thread/queue. In your example I guess you should also reload the tableview only when your data has been fetched, so in the completion block, and not before the callback has been called.

    // Begin to fetch all of the items
    dispatch_async(queue, ^{
       [store allObjectsOfClass:[Inventory class]
           additionalOptions:nil
                    callback:^(CMObjectFetchResponse *response) {
    
                    // block execution to fetch data
                    ...
                    // load data on local data structure
                    ...
    
                    // Ask the main queue to reload the tableView
                    dispatch_async(dispatch_get_main_queue(), ^{
                        // Alsways perform such code on the main queue/thread
                        [self.tableView reloadData];
                    });
        }];
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having issue with displaying the Data from a second Activity. when I run the
Having an issue here that I have tried everything I can think of but
I am having issue connecting from ROR 3.2 to Oracle database. irb(main):001:0> gem 'ruby-oci8',
I am having issue when sending data from Service to Activity through Notification ,
I having issue that content assistant / intellisense is working in methods such as
Hi guys I am having issue I have this query: SELECT * FROM useraccount
I am having issue with opencv's Sobel edge detector. From its documentation it seems
I'm having issue with Action Listener of a JTable that being updated according the
We have a device that support SAE J1939 interface and having issue with finding
I want to filter a list of entities that I am fetching from a

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.