gpt4 book ai didi

ios - 整理 MPMediaQuery 时转义标点符号和歌曲标题中的 'The' 前缀

转载 作者:可可西里 更新时间:2023-11-01 17:10:38 24 4
gpt4 key购买 nike

该代码可以正常工作并用部分填充表格,但它有一个缺陷:它不会转义歌曲标题中的标点符号和“The”前缀,就像 native 音乐应用程序所做的那样。

非常希望能就我应该如何做这件事提供一些指导。

- (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;
}

最佳答案

我完全忽略了这一点。这里的答案是简单地使用 MPMediaQuerySection。 Apple 文档的存在是有原因的!

关于ios - 整理 MPMediaQuery 时转义标点符号和歌曲标题中的 'The' 前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9750766/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com