Ios UILocalizedIndexedCollation-[\uu NSCFNumber length]:发送到实例的无法识别的选择器

Ios UILocalizedIndexedCollation-[\uu NSCFNumber length]:发送到实例的无法识别的选择器,ios,objective-c,indexing,Ios,Objective C,Indexing,获取此错误-[\uu NSCFNumber length]:无法识别的选择器发送到实例我做错了什么? songName是一个NSString,因此长度应该响应 // Song.h @property (nonatomic, retain) NSNumber * pID; @property (nonatomic, retain) NSString * serverID; @property (nonatomic, retain) NSString * songName; @property (

获取此错误
-[\uu NSCFNumber length]:无法识别的选择器发送到实例
我做错了什么?
songName
是一个NSString,因此长度应该响应

//  Song.h
@property (nonatomic, retain) NSNumber * pID;
@property (nonatomic, retain) NSString * serverID;
@property (nonatomic, retain) NSString * songName;
@property (nonatomic, retain) NSString * songURL;
//主视图

NSArray *indexedBooks = [self partitionObjects:self.songArray collationStringSelector:@selector(songName)];


-(NSArray *)partitionObjects:(NSArray *)array collationStringSelector:(SEL)selector
{
    self.collation = [UILocalizedIndexedCollation currentCollation];
    NSInteger sectionTitlesCount = [[self.collation sectionTitles] count];//section count is take from sectionTitles and not sectionIndexTitles
    NSMutableArray *unsortedSections = [NSMutableArray arrayWithCapacity:sectionTitlesCount];

    NSLog(@"sectionTitleCount %i",sectionTitlesCount);

    //create an array to hold the data for each section
    for(int i = 0; i < sectionTitlesCount; i++)
    {
        [unsortedSections addObject:[NSMutableArray array]];
    }
    //put each object into a section
    for (id object in array)
    {
        NSInteger index = [self.collation sectionForObject:object collationStringSelector:selector];
        [[unsortedSections objectAtIndex:index] addObject:object];
    }

    NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionTitlesCount];

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

    NSLog(@"sections %@",sections); //error pointed to this line

    return sections;    

}
NSArray*indexedbook=[self-partitionObjects:self.songArray排序规则stringselector:@selector(songName)];
-(NSArray*)分区对象:(NSArray*)数组排序规则字符串选择器:(SEL)选择器
{
self.collation=[UILocalizedIndexedCollation currentCollation];
NSInteger sectionTitlesCount=[[self.collation sectionTitles]count];//节计数取自sectionTitles,而不是sectionIndexTitles
NSMUTABLEARRY*unsortedSections=[NSMUTABLEARRY阵列容量:sectionTitlesCount];
NSLog(@“sectionTitleCount%i”,sectionTitleCount);
//创建一个数组以保存每个节的数据
对于(int i=0;i
在我的cellForRowAtIndexPath上被证明是一个打字错误

-(NSArray *)partitionObjects:(NSArray *)array collationStringSelector:(SEL)selector
{
    self.collation = [UILocalizedIndexedCollation currentCollation];
    NSInteger sectionCount = [[self.collation sectionTitles] count];//section count is take from sectionTitles and not sectionIndexTitles
    NSMutableArray *unsortedSections = [NSMutableArray arrayWithCapacity:sectionCount];
    //create an array to hold the data for each section
    for(int i = 0; i < sectionCount; i++)
    {
        [unsortedSections addObject:[NSMutableArray array]];
    }
    //put each object into a section
    for (id object in array)
    {
        NSInteger index = [self.collation sectionForObject:object collationStringSelector:selector];
        [[unsortedSections objectAtIndex:index] addObject:object];
    }

    NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount];

    //sort each section
    for (NSMutableArray *section in unsortedSections)
    {
        [sections addObject:[self.collation sortedArrayFromArray:section collationStringSelector:selector]];
    }
    return sections;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    SongCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.songName setFont:[UIFont fontWithName:monB size:17]];
    [cell.songArtistAlbum setFont:[UIFont fontWithName:monR size:10]];
    [cell.songArtistAlbum setTextColor:kCategoriesColor];

    if ( [[self.sectionsArray objectAtIndex:indexPath.section] count] != 0)
    {
        Song* songItem = [[self.sectionsArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
        [cell.songName setTextColor:[self returnSongMoodColor:[songItem.mood intValue]]];
        NSString  *subText =[NSString stringWithFormat:@"%@  %@",[songItem.artistName length]>0 ? songItem.artistName : @"Unknown Artist", [songItem.albumTitle length]>0 ? songItem.albumTitle : @"Unknown Album"];
        NSMutableAttributedString *subTextAString = [[NSMutableAttributedString alloc]initWithString:subText];
        NSRange rangeAlbum = [subText rangeOfString:[songItem.albumTitle length]>0 ? songItem.albumTitle : @"Unknown Album"];
        [subTextAString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:rangeAlbum];
        [cell.songName setText:songItem.songName];
        [cell.songArtistAlbum setAttributedText:subTextAString];
        [cell.moodImg setImage:self.moodImg];

            return cell;
    }
    return nil;
}
-(NSArray*)分区对象:(NSArray*)数组排序规则字符串选择器:(SEL)选择器
{
self.collation=[UILocalizedIndexedCollation currentCollation];
NSInteger sectionCount=[[self.collation sectionTitles]count];//节计数取自sectionTitles,而不是sectionIndexTitles
NSMUTABLEARRY*unsortedSections=[NSMUTABLEARRY阵列容量:sectionCount];
//创建一个数组以保存每个节的数据
对于(int i=0;i0?songItem.artistName:@“未知艺术家”,[songItem.albumTitle长度]>0?songItem.albumTitle:@“未知专辑”];
NSMutableAttributedString*SubtextString=[[NSMutableAttributedString alloc]initWithString:subText];
NSRange rangeAlbum=[子文本rangeOfString:[songItem.albumTitle长度]>0?songItem.albumTitle:@“未知唱片”];
[子文本搜索addAttribute:NSForegroundColorAttributeName值:[UIColor whiteColor]范围:rangeAlbum];
[cell.songName setText:songItem.songName];
[cell.songArtistAlbum setAttributedText:下文本存储];
[cell.moodImg setImage:self.moodImg];
返回单元;
}
返回零;
}

它在哪一行崩溃?由于您试图访问
NSNumber
length
而导致崩溃,这不是
NSNumber
的属性。添加一个异常断点,查看您面临的问题。Hi@croyneaus4u,错误指向我的NSLOG,在我注释掉该行后,我得到了一个超出范围的错误。