0

I am trying to complete a task, and then want the xib content to be shown on the view. However the VC is being initialized via nibFile, is there a way to do lazy loading of nib once the task is completed?

Thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579
topgun
  • 2,463
  • 8
  • 31
  • 46

2 Answers2

1

in viewDidLoad:

self.view.hidden = YES;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // do your background tasks here
    [self doSomethingInBackground];

    // when that method finishes you can run whatever you need to on the main thread
    dispatch_async(dispatch_get_main_queue(), ^{
        self.view.hidden = NO;
    });
});

(adapted from Implement a block in background, then after completion run another block on main thread?)

Community
  • 1
  • 1
jsd
  • 7,673
  • 5
  • 27
  • 47
0

Put the task in a background thread, when this finish refresh the main thread to load the nib.

Remember, the view in iOS application run in Main thread, if you are doing a task and this no finish quickly, the best way is run the task in background.

Nekak Kinich
  • 905
  • 7
  • 10