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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:14:22+00:00 2026-05-26T09:14:22+00:00

I have a NSTabView with several tab view items. When a user hits a

  • 0

I have a NSTabView with several tab view items. When a user hits a certain button, the tabview changes to one of these items to display things returned from a website api. I tried to create an intermediate tab view item to tell the user that it is fetching the data and then once fetched it will display it.

[tabView selectTabViewItemAtIndex:0]; // This is the intermediate tab
/* 
   Fetching 
   data from
   the api
   here
*/
[tabView selectTabViewItemAtIndex:1]; // Displaying the data tab

But the first tab never gets shown, only the last one. I wondered if it was just getting the data very quickly and didn’t have time to show it, but I set a breakpoint halfway through but it still hadn’t been changed. It only seems to be getting changed at the end, weird.

Any ideas?

Update:

Thanks for the answer, fixed it as follows

[tabView selectTabViewItemAtIndex:0]; // This is the intermediate tab

dispatch_queue_t queue = dispatch_queue_create("com.mycompany.queue", 0);
dispatch_async(queue, ^{
    /* 
       Fetching 
       data from
       the api
       here
    */
    [tabView selectTabViewItemAtIndex:1]; // Displaying the data tab
});
  • 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-26T09:14:22+00:00Added an answer on May 26, 2026 at 9:14 am

    Does the API that fetches data operate synchronously? I’m willing to bet that it does.

    The user interface is only going to update at the end of the run loop running on the main thread. If the API that handles the fetching runs in the same thread then things are going to end up working like this:

    1. Begin Run Loop
    2. You Select Tab Index 0
    3. You fetch the data.
    4. You Select Tab Index 1
    5. The UI updates, displaying tab index 1.

    You probably need to run your data fetch routines in a background thread. Then when it returns data, tell the NSTabView to select tab index 1. Since the data fetch occurs in the background, the run loop will have a chance to update the UI more than once which should result in tab index 0 becoming visible (for a short while anyway).

    You can run the data fetch in the background using a couple of different methods. The obvious ones are to use Grand Central Dispatch or you could also use the “performSelectorInBackground:” series of methods that are part of the NSObject protocol.

    Also you should ALWAYS be very careful about what operations you perform on the main thread. Fetching data from a website could take a while. If you run that operation synchronously on the main thread then the user interface will be completely non responsive while you wait for that data fetch to complete. Apple talks about this in their documentation on multithreading.. Definitely worth a read. That and Grand Central Dispatch – it makes multithreading much much easier.

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

Sidebar

Related Questions

I have a view-based NSTableView that usually has one column in it. However, at
I have a NSTabView with a number of NSView items. I want to resize
I have a NSTableView that contains a NSButtonCell in one of the columns. I
I have a custom NSTableView subclass filled with several custom NSTextFieldCell subclasses. I would
I have an NSTableView that has 2 columns, one for an icon and the
I have a NSTabView, where I alloc and load the same NSViewController on its
I have a NSTableView that is bound using Cocoa Bindings. One column of that
In my project, I have two Core Data entities. One is the grouping (can
How would I make an NSTableView display an RSS Feed (just one)? I think
I have an editing window with several fields, all bound to the 'content' controller

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.