1

我正在用符合特定条件的歌曲填充数组。

  NSArray *songs = [[[MPMediaQuery alloc] init] items];
  NSMutableArray *filteredSongs;
  for (int i=0; i<[songs count]; i++) {
       // filter logic here: if songs[i] match the criteria, push it filteredSongs array

  }

现在我想按 排序该数组MPMediaItemPropertyAlbumTitle,但如果用户 mp3 的专辑信息丢失,则避免出现问题。(我正在尝试为此处解决的问题找到解决方法)

4

1 回答 1

1

您可以使用NSComparisonResult按专辑标题排序。这应该处理 nil albumTitle 值并将它们推到后面。

[songs sortUsingComparator:^NSComparisonResult(id obj1, id obj2){
return [[obj2 albumTitle] compare:[obj1 albumTitle]];
}];
于 2014-02-06T17:19:33.073 回答