For a sectioned tableView I need to sort my books by category.sortOrder
NSMutableDictionary *theDictionary = [NSMutableDictionary dictionary];
for (Book *object in self.books) {
NSMutableArray *theMutableArray = [theDictionary objectForKey:object.category.categoryName];
if ( theMutableArray == nil ) {
theMutableArray = [NSMutableArray array];
[theDictionary setObject:theMutableArray forKey:object.category.categoryName];
}
[theMutableArray addObject:object];
}
self.sections = [[theDictionary allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
How can I include the category.sortOrder value in my Dictionary, so I can sort my sections correctly?
For clarity, you should create a class to hold the values for each section, then add those to your dictionary. You can do this all in your controller if you don’t want the extra file, but you could also create another file if you wanted: