iOS - 截取数组前几个元素放入新的数组,剩余的放入另外一个数组
NSArray *array = [NSArray arrayWithObjects:@"Crystal",@"Maisie",@"Lukas",@"Ruben",@"Brooklynn",@"Melody",@"Imogen",@"Skye",@"Rafael",@"Lindsey",@"Felix",nil]; NSArray *topThree = [array subarrayWithRange:NSMakeRange(0, 3)]; NSArray *remaining = [array subarrayWithRange:NSMakeRange(3, array.count-3)]; NSLog(@"topThree:%@=======remaining:%@",topThree,remaining); topThree:[ Crystal, Maisie, Lukas ]=======remaining:[ Ruben, Brooklynn, Melody, Imogen, Skye, Rafael, Lindsey, Felix ]
天行健,君子以自强不息;地势坤,君子以厚德载物!