I have a Music App I am developing, and while I'm managing the TableViews, I'm sorting them into Sections. This is usually an easy process, but the with the way I manage I manage the data, it might not be a completely simple task.
I know it's not the best way to do it, but as the cell has multiple properties (titleLabel, textLabel, imageView), I store all the data in 3 separate arrays. When organising the songs by title, for section header, I use a predicate to set the titleLabel, so by using this code.
NSArray *predict = [mainArrayAll filteredArrayUsingPredicate:predicate];
cell.titleLabel.text = [predict objectAtIndex:indexPath.row];
Unfortunately, I also have a otherArrayAll, and others. These all have data such as the artist name, album artwork and so need to be relative to the songs they are for. Is there a way to reorder these other arrays in the same way the mainArrayAll array is? So the relative data is kept together?
In the above case I would suggest you to create a model class implementation to store all the values. Following MVC architecture is the best way here.
For eg:-
Now if you want to create an array of music, do it as:
Now to sort this array:
If you want to use predicates:
If you want to use these properties in a table view or so, you can use it as: