Ios 排序对象描述

Ios 排序对象描述,ios,uitableview,nsdictionary,Ios,Uitableview,Nsdictionary,我有一个包含多个部分的tableview,按我的对象(日期)的属性分组。我尝试根据日期的值对tableview进行排序。我为此创建了一个函数,但出现错误: - (void)sortObjectsDictionnary:(NSArray *)arrayObjects { //this is my nsdictionnary [objects removeAllObjects] //this is nsmutableaaray that contains dats [objectsI

我有一个包含多个部分的tableview,按我的对象(日期)的属性分组。我尝试根据日期的值对tableview进行排序。我为此创建了一个函数,但出现错误:

- (void)sortObjectsDictionnary:(NSArray *)arrayObjects
{
//this is my nsdictionnary
    [objects removeAllObjects]
//this is nsmutableaaray that contains dats
    [objectsIndex removeAllObjects];

    NSMutableSet *keys = [[NSMutableSet alloc] init];

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy/MM/dd"];

    for(int i=0;i<[arrayObjects count];i++){
        Task *myTask=[arrayObjects objectAtIndex:i];

//curentsection contains my objects whith dates
            NSMutableArray *currentSection = [objects objectForKey:taskDate];

            if (currentSection == nil)
            {
                [keys addObject:taskDate];

                currentSection = [[[NSMutableArray alloc] init] autorelease];

                [objects setObject:currentSection forKey:taskDate];


            }

            // we add objet to the right section
            [currentSection addObject:myTask];

    }
    [dateFormatter release];


    for (id element in keys) 
    { 
        [objectsIndex addObject:element];

        NSMutableArray *currentSection = [objects objectForKey:element];

        //I get an error in this line
        [currentSection sortUsingSelector:@selector(compare:)];

    }
-(void)SortobjectsDictionary:(NSArray*)阵列对象
{
//这是我的毕业典礼
[对象移除所有对象]
//这是包含DAT的NSMUTABLEARAY
[对象索引删除所有对象];
NSMutableSet*键=[[NSMutableSet alloc]init];
NSDateFormatter*dateFormatter=[[NSDateFormatter alloc]init];
[日期格式化程序setDateFormat:@“yyyy/MM/dd”];

对于(int i=0;i您没有提到错误消息是什么,我假设错误消息可能是由于在未初始化NSMutableArray对象的情况下访问该对象造成的。请在之前尝试数组的alloc和init NSMUTABLEARRY*currentSection=[NSMUTABLEARRY]alloc]init]; currentSection=[objects objectForKey:element]

    //I get an error in this line
    [currentSection sortUsingSelector:@selector(compare:)];
这纯粹是猜测。如果不起作用,请发布错误消息


Bharath

那么,错误在哪里?在这一行:[currentSection sortUsingSelector:@selector(比较:)];错误消息是什么?它崩溃了,因为[currentSection sortUsingSelector:@selector(比较:)];我认为它用于比较字符串值这不是Xcode问题。不,它包含在对nsarray进行排序的语法中!错误很可能类似于
[NSMutableArray compare:]无法识别的选择器