を照合する場合、句読点、および曲のタイトルに「」プレフィックスを脱出し、セクションを持つテーブルを移入し、それが欠陥を持っている:それはちょうど、句読点や曲のタイトルに「」プレフィックスをエスケープしません。ネイティブ音楽アプリの仕組みと同じように。は、コードの作品MPMediaQuery
は本当に私はこれをやって行くべきかにいくつかの指導をお願い申し上げます。
- (void)viewDidLoad
{
[super viewDidLoad];
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
self.songsArray = [songQuery items];
self.sectionedSongsArray = [self partitionObjects:self.songsArray collationStringSelector:@selector(title)];
}
- (NSArray *)partitionObjects:(NSArray *)array collationStringSelector:(SEL)selector
{
UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation];
NSInteger sectionCount = [[collation sectionTitles] count];
NSMutableArray *unsortedSections = [NSMutableArray arrayWithCapacity:sectionCount];
for(int i = 0; i < sectionCount; i++)
{
[unsortedSections addObject:[NSMutableArray array]];
}
for (id object in array)
{
NSInteger index = [collation sectionForObject:object collationStringSelector:selector];
[[unsortedSections objectAtIndex:index] addObject:object];
}
NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount];
for (NSMutableArray *section in unsortedSections)
{
[sections addObject:[collation sortedArrayFromArray:section collationStringSelector:selector]];
}
return sections;
}
あなたはこれを実装する方法共有してもらえますか?私は同じことにこだわっていて、私は夢中になる!そして、それは他のMPMediaItems/MPMediaCollectionsのリストのために働くのでしょうか?おかげ – topLayoutGuide
私はpartitionObjects方法で私の全体のメディアライブラリを書きました。これは、ある程度まで「迅速」ですが、これはMPMediaQuerySectionとLOT高速です。助けていただければ幸いです! – topLayoutGuide