Note that there are some explanatory texts on larger screens.

plurals
  1. POImprove the performance of uitableview creation with many sections from sqlite database
    primarykey
    data
    text
    <p>This is my scenario:</p> <p>Sqlite database with 30000 products with 800 different brands.</p> <p>Table product is like this:</p> <pre><code>id | title | brand | other fields </code></pre> <p>Products example:</p> <pre><code>1221 | Product 1 | brand 1 | ... 1222 | Product 2 | brand 2 | ... 1223 | Product 3 | brand 2 | ... 1224 | Product 4 | brand 3 | ... 1225 | Product 5 | brand 3 | ... 1226 | Product 6 | brand 3 | ... </code></pre> <p>I need to create a uiviewtable with all products in different sections. Sections are different brands of products.</p> <p>I must implements this methods:</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath </code></pre> <p>My idea to solve this problem is as follows (written in pseudocode):</p> <pre><code>NSArray * productList = [databaseManager getProductList]; //array with Product model objects NSArray * brandsList = [databaseManager getBrandsList]; NSMutableDictionary * dictionaryProductBrands = [NSMutableDictionary dictionaryWithCapacity:bramdsList.count]; for (NSString *brand in brandsList) { NSMutableArray *arrayProductsPerBrands = [NSMutableArray array]; for (Product *p in productList) { if ([p.brand isEqualToString:brand]) { [arrayProductsPerBrands addObject:p]; } } [dictionaryProductBrands setValue:arrayProductsPerBrands forKey:brand]; } </code></pre> <p>This solution has a poor performance.</p> <p>Can I improve the way to generate the tableview with sections with the same database?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload