NSMutableArray *array = [NSMutableArray arrayWithObjects:@"1",@"1",@"2",@"3",@"1",@"5", nil];
for (int i=0; i<array.count; i++) {
NSString *str = array[i];
if ([str isEqualToString:@"1"]) {
[array removeObjectAtIndex:i];
i--;
}
}
NSLog(@"%@",array);
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"1",@"1",@"1",@"1",@"2",@"2",@"3",@"1",@"2",@"2",@"5",@"8888", nil];
for (int i=0; i<array.count; i++) {
NSString *str1 = array[i];
for (int j=i+1; j<array.count; j++) {
NSString *str2 = array[j];
if ([str2 isEqualToString:str1]) {
[array removeObjectAtIndex:j];
j--;
}
}
}
NSLog(@"%@",array);
网友评论