As I understand it, this should lead to @"12",@"34",@"56"
NSArray *arr = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",nil]; NSMutableArray *array2 = [NSMutableArray array]; [arr enumerateObjectsUsingBlock:^(NSString *string1, NSUInteger idx, BOOL *stop) { if (idx > 0 && idx %2 == 1) { NSString *string0 = [arr objectAtIndex:idx-1]; [array2 addObject:[NSString stringWithFormat:@"%@%@", string0, string1]]; } }]; NSLog(@"%@", array2);
result:
( 12, 34, 56 )
source share