0

Currently I have a table that is updated by a server query, so it is not instant. Currently I populate the array in the viewDidLoad delegate method like so:

- (void)viewDidLoad
{
    [super viewDidLoad];    
    followers = [[User sharedManager] loadFollowers];    
}

However, what happens is that I press the button to modal transition into the tableview and it then waits for the query to succeed and only then pulls up the view. Obviously this is really annoying since it feels like it's crashing/lagging. I'd rather it pulls up the page instantly and has a "loading..." or an activity view while the query executes. How can I do this?

4

2 に答える 2

0

多くのネットワーキングを行う場合は、ネットワーキングを簡単にするNSURLConnectionようなクラスやライブラリを検討する必要があります。AFNetworking

ネットワーク関連がメイン (UI) スレッドで実行されないようにする必要があります。このようにgcdでこれを行うことができます

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  self.followers = [[User sharedManager] loadFollowers];
  dispatch_async(dispatch_get_main_queue(), ^{
    // update the UI now new data has been stored
    // e.g. [self reloadData];
  });
});
于 2013-11-04T21:32:10.367 に答える