views:

10

answers:

2

I have an application that requires loading data from a network for a UITableView from the Internet. However, this delays the loading of the view controller. Any ideas?

A: 

Try:

#pragma mark -
#pragma mark Helpers
#pragma mark -


- (void)load
{
 [NSThread sleepForTimeInterval:4.0];
 self.results = [NSArray arrayWithObjects:@"Canada", @"England", @"France", @"Spain", nil];
 [self.view performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}


#pragma mark -
#pragma mark Main
#pragma mark -


- (void)viewDidLoad
{
 [super viewDidLoad];

 NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
 [queue addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(load) object:nil] autorelease]];
}
Kevin Sylvestre
+1  A: 

You should be using threading to perform long running tasks. Are you not currently?

BobbyShaftoe