NSArray * arr = @[@"1",@"2",@"3",@"4",@"5"];
//是否包含
if([arr containsObject:@"3"]) {
NSInteger index = [arr indexOfObject:@"3"];
NSLog(@"-1---%ld---",index);
}
//输出是 2
//////////22222222
if([arr indexOfObject:@"5"] != NSNotFound) {
NSInteger inde =[arr indexOfObject:@"5"] ;
NSLog(@"-2---%ld----",inde);
}else{
NSLog(@"不存在");
}
//////22222---->>>>3333333
NSInteger inde =[arr indexOfObject:@"5"];
if(inde != NSNotFound) {
NSLog(@"-2---%ld----",inde);
}else{
NSLog(@"不存在");
}
网友评论