Xcode NSInvalidArgumentException ', причина:' - [__ NSArrayM isEqualToString:] Ошибка - PullRequest
0 голосов
/ 17 февраля 2011

Мне нужна помощь здесь. Я получил эту ошибку «NSInvalidArgumentException», причина: «- [__ NSArrayM isEqualToString:]», когда я пытался запустить свое приложение. Кто-нибудь может определить ошибку, которая у меня есть? Это мои коды ...

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar

{


sBar.showsCancelButton = YES;

sBar.autocorrectionType = UITextAutocorrectionTypeNo;

[tableData removeAllObjects];


myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 40, 320, 440)];
myTableView.delegate = self;
myTableView.dataSource = self;
[self.view addSubview:myTableView];
//initialize the two arrays; dataSource will be initialized and populated by appDelegate
searchedData = [[NSMutableArray alloc]init];
tableData = [[NSMutableArray alloc]init];

dataSource= [[NSMutableArray alloc]init];

Service *aService;
for(int i=0; i<[appDelegate.blocks count]; i++){
    aService = [appDelegate.blocks objectAtIndex:i];

    [dataSource addObject:[aService name]];


}
//dataSource = [dataSource sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

//NSLog(@"%@",dataSource);


NSMutableArray *newSectionsArray = [[NSMutableArray alloc] initWithCapacity:26];// = [[NSMutableArray alloc] initWithCapacity:26];
for (int index = 0; index < 26; index++) {
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [newSectionsArray addObject:array];

    [array release];
}



for(int i=0; i<[dataSource count]; i++){
    NSString *miscKey = @"#";
    NSString *try;
    NSString *Represent =[dataSource objectAtIndex:i];
    NSLog(@"%@",Represent);
    try=([Represent length] ==0)?miscKey:[[Represent substringToIndex:1]uppercaseString];

    if([try isEqualToString: @"A"]){
        NSLog(@"a");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:1];
        [sectionTimeZones addObject:Represent];
        NSLog(@"a  %@",Represent);
    }
    else if([try isEqualToString: @"C"]){
        NSLog(@"c");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:3];
        [sectionTimeZones addObject:Represent];
        NSLog(@"c  %@",Represent);

    }
    else if([try isEqualToString: @"D"]){
        NSLog(@"d");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:4];
        [sectionTimeZones addObject:Represent];
        NSLog(@"d  %@",Represent);

    }
    else if([try isEqualToString: @"N"]){
        NSLog(@"n");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:9];
        [sectionTimeZones addObject:Represent];
        NSLog(@"n  %@",Represent);

    }
    else if([try isEqualToString: @"O"]){
        NSLog(@"o");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:10];
        [sectionTimeZones addObject:Represent];
        NSLog(@"o  %@",Represent);          
    }
    else if([try isEqualToString: @"P"]){
        NSLog(@"p");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:11];
        [sectionTimeZones addObject:Represent];
        NSLog(@"p  %@",Represent);

    }
    else if([try isEqualToString: @"S"]){
        NSLog(@"s");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:14];
        [sectionTimeZones addObject:Represent];
        NSLog(@"s  %@",sectionTimeZones);           
    }
    else if([try isEqualToString: @"T"]){
        NSLog(@"t");
        NSMutableArray *sectionTimeZones = [newSectionsArray objectAtIndex:15];
        [sectionTimeZones addObject:Represent];
        NSLog(@"t  %@",Represent);          
    }
    else{}



}   

//NSLog(@"%@",newSectionsArray);
[tableData addObjectsFromArray:newSectionsArray];

    //[tableData addObjectsFromArray:dataSource];

}

1 Ответ

0 голосов
/ 21 февраля 2011

Возможно, это связано с использованием «try» в качестве переменной.Попробуйте переименовать его во что-то другое и попробовать!

...