I want to do a basic sorting of a UITableView
that is generated from MPMediaQuery
.
What I want is to just have a basic songs list that sorts the songs into sections of A, B, C, D, etc. Shouldn't be hard, but every tutorial I've tried to follow ends up no giving me those results at all.
Any help would be wonderful. Here is my basic code. I realize this is not even close to having what I want accomplished, but I figured it would be easier for a seasoned developer to help me from this point then the mess I was in.
How I generate my data:
MPMediaQuery *musicLibraryQuery = [[MPMediaQuery alloc] init];
NSArray *musicLibraryArray = [musicLibraryQuery items];
songLibrary = [NSMutableArray arrayWithArray:musicLibraryArray];
These are my UITableView methods:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [songLibrary count];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"SongCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
MPMediaItem *song = [[songLibrary objectAtIndex:[indexPath row]] representativeItem];
cell.textLabel.text = [song valueForProperty:MPMediaItemPropertyTitle];
return cell;
}
u need to sort array for example