0

I am trying to have the following method call, sorted. Can I use sortdescriptors? If so how should I do it?

NSArray *subcategoriesNames = [self.dataManager getSubcategoriesOfCategory:self.category];
for (SubcategoryEntity *subcategory in subcategoriesNames) {
      NSLog(@"print all subcategories %@",subcategory.icon);
      NSLog(@"print all subcategories %@",subcategory.title);
      BaseTableItem *item = [[BaseTableItem alloc] initWithText:subcategory.title andIcon:subcategory.icon];
        [self.tableItems addObject:item];
        [item release];

I need that subcategoriesNames gets sorted before its used in the loop.

Datamanager is a Coredata object. Its retrieving a set of rows from a database, each row has a title and an icon. I need the sort to happen by title.

Kampai
  • 22,848
  • 21
  • 95
  • 95
jason
  • 5,391
  • 6
  • 23
  • 26
  • David how do you get the code to show like that? – jason Apr 18 '11 at 02:34
  • You indent it by 4 spaces, or (easier) click on the button with the "{}" icon – David Gelhar Apr 18 '11 at 02:37
  • 1
    possible duplicate of [How to sort NSMutableArray using sortedArrayUsingDescriptors ?](http://stackoverflow.com/questions/1844031/how-to-sort-nsmutablearray-using-sortedarrayusingdescriptors) -- very good answers there. – David Gelhar Apr 18 '11 at 02:41

1 Answers1

0

possible duplicate of How to sort NSMutableArray using sortedArrayUsingDescriptors ? -- very good answers there. – David Gelhar Apr 18 at 2:41

jason
  • 5,391
  • 6
  • 23
  • 26