Finally, this comment-based solution: Run the stream in viewDidLoad to get the data without blocking everything:
- (void) viewDidLoad { dataLoaded = NO; [self initSpinner]; [self launchLoadData]; ... } -(void)launchLoadData { NSLog(@"Launching thread"); [NSThread detachNewThreadSelector:@selector(loadData) toTarget:self withObject:nil]; } - (void) loadData { dataLoaded = NO; NSLog(@" thread launched"); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self loadDataFromURL:nil]; dataLoaded = YES; [self.tableView reloadData]; [pool release]; } - (void)loadDataFromURL:(NSString*)url {
and use the flag to display or missing data in the table. tableView reloadData will do the rest when called from the stream.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (dataLoaded) return [self.accounts count]; return 0; }
Christophe HAMERLING
source share