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

  • Home
  • SEARCH
  • 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 6923027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:28:58+00:00 2026-05-27T10:28:58+00:00

I am calling the following Class method from within my ViewController init method: [NSURLConnection

  • 0

I am calling the following Class method from within my ViewController init method:

[NSURLConnection sendAsynchronousRequest:urlrequest 
                                   queue:opQueue 
                       completionHandler:^(NSURLResponse *response, NSData *data, NSError*error){


// Update an NSMutableArray (an Instance variable

[self tableView] reloadData]; // is this ok to call?
}];

This code working as intended and tableView refreshes appropriately, My concern: is this call thread safe?. is it ok to access an UI element from the completion block?

Thanks,

Vinod

  • 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-27T10:28:59+00:00Added an answer on May 27, 2026 at 10:28 am

    Actually, this is not correct unless opQueue happens to be +[NSOperationQueue mainQueue]

    That completion block will be scheduled on the queue you provide. In your case, you’re calling that queue ‘opQueue’. If that queue is being drained by some thread other than the main thread, then you shouldn’t make that call to reload the tableview there.

    You should instead do whatever processing you need to do and then enqueue another block on the main queue which calls the reload.

    ^(NSURLResponse *response, NSData *data, NSError*error){
    
       // Do some processing work in your completion block
    
       dispatch_async(dispatch_get_main_queue(), ^{
    
        // Back on the main thread, ask the tableview to reload itself.
        [someTableView reloadData];
    
       });
    }
    

    Or if the processing is light and quick (and fixed amount of time), then just pass the mainQueue as the ‘opQueue’;

    I hope that makes sense. A lot of good information to be found here: Concurrency Programming Guide

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

Sidebar

Related Questions

I have a view with which I have a button calling the following method.
I have the following code (calling a method returning IEnumerable): FibonacciWithLinq.Skip(delegate() { return 5;
I am sending emails with the following method: class Communicate < ActionMailer::Base def message(sub,msg,people)
At the following link Calling clojure from java , it is illustrated how to
I got this following method in an non Activity class, My code is below.
I am having a problem with JNI, calling a method from C++ to Java.
I would like to invoke a simple method (no arguments, returns void) from within
I am currently calling the following line of code: java.net.URL connection_url = new java.net.URL(http://<ip
I'm calling the following URL using YQL http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22UTG.L%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=cbfunc this returns the following in JSON
Am getting following error message on calling WCF service: The formatter threw an exception

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.