关于功能的简单错误

时间:2014-01-02 07:35:26

标签: ios objective-c uitableview indexing uilocalizedcollation

我想在我的tableview上显示一个索引栏,我的所有歌曲按字母顺序排序,#中的外语歌曲就像iOS中的iPod音乐一样。左右。 但是我得到了一个错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LibraryViewController partitionSongObjects:collationStringSel:]: unrecognized selector sent to instance 0x1454be90'

非常感谢任何评论。

// viewDidLoad中

 [[MediaService sharedService]getAllSongsItemInSongs:^(NSArray *data) {
    self.songArray = [[NSMutableArray alloc]initWithArray:data];
    }];

    NSMutableArray *songNameArray = [NSMutableArray array];

    for (Song *songNameItem in self.songArray)
    {
        [songNameArray addObject:songNameItem.songName];
    }
    self.sectionArray = [self partitionSongObjects:songNameArray collationStringSel:@selector(songName)];
    [self.songLibraryTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];


- (NSMutableArray *)partitionObjects:(NSArray *)array collationStringSelector:(SEL)selector
{
    self.collation = [UILocalizedIndexedCollation currentCollation];
    NSInteger sectionCount = [[self.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 = [self.collation sectionForObject:object collationStringSelector:selector];
        [[unsortedSections objectAtIndex:index] addObject:object];
    }

    NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount];

    for (NSMutableArray *section in unsortedSections)
        [sections addObject:[self.collation sortedArrayFromArray:section collationStringSelector:selector]];

    return sections;
}

1 个答案:

答案 0 :(得分:1)

你有一个简单的错误输入方法名称:[self partitionSongObjects:songNameArray collationStringSel:@selector(songName)]而你可能应该: [self partitionSongObjects:songNameArray collationStringSelector:@selector(songName)]