删除重复项后以及在ios中排序后如何在表中加载数据

时间:2013-12-02 09:35:04

标签: ios uitableview nsmutablearray

嗨在我的一个应用程序中,我必须在tableview中加载数据。在加载数据之前,我必须做两个操作

  1. 从数据中删除重复项(数据在数组中)。 2.根据产品名称和产品SKU编号分类数据。
  2. 我使用下面的代码实现了这些功能,但问题是它正在谈论很长时间在tableview中显示数据。请任何人都可以帮助我如何解决这个问题。请帮帮我。

     NSArray *array = [NSArray arrayWithArray:ProductsArray];
    
     NSArray *uniquearray = [[NSSet setWithArray:array] allObjects];
    
     ProductsArray=[NSMutableArray arrayWithArray:uniquearray];
    
     // Sort Based on Product name and SKU  Number
    
     NSSortDescriptor *ProductDescription = [[NSSortDescriptor alloc] initWithKey:@"Product" ascending:YES];
     // String are alphabetized in ascending order
     NSSortDescriptor *SKUDescription = [[NSSortDescriptor alloc] initWithKey:@"SKU" ascending:YES];
     // Combine the two
     NSArray *sortDescriptors = @[ProductDescription, SKUDescription];
     // Sort your array
     NSArray *sortedArray = [ProductsArray sortedArrayUsingDescriptors:sortDescriptors];
    
     ProductsArray=[NSMutableArray arrayWithArray:sortedArray];
    

0 个答案:

没有答案