I Have a CSV File that contain 6000 rows.
I would like to Populate those 6000 rows in a TableView Then Use a SearchBar to fetch a single row
I used CSVParser but it needs 10 minutes to load the UITableview:
-(void)ViewDidLoad{
CSVParser *parser = [CSVParser sharedInstance];
NSDictionary *dictionary = [parser parseCSVFile: @"ports"];
NSArray* rows = [dictionary allKeys];
}
Then to Populate the tableview:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 25;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
PortListCell *cell = (PortListCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.Codeport.text = [[rows objectAtIndex:indexPath.row]valueForKey:@"ident"];
cell.Nameport.text = [[rows objectAtIndex:indexPath.row]valueForKey:@"name"];
NSString*CodeCountry = [[[rows objectAtIndex:indexPath.row]valueForKey:@"iso_country"]lowercaseString];
cell.ImageCountry.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",CodeCountry]];
return cell;
}
What is the best way to populate a UITableView with these rows ?
Loading large amounts of data into table views, which will never show the whole amount of data anyway, is commonly done asynchronously, with periodic updates. If you can get into the CSV parser, perhaps it could add rows to the array and call tableview reloadData every 10 rows or something. That way your slow parsing and tableview update would happen in the background, as the table view was already appearing active to the user.