Question: I have a NSArray with possibly hundreds of elements. I want to remove every element but the 20 first ones. Ideas?

Answer: 
If your array is an NSArray, then you can't remove objects since it's immutable. You'll need to do something like Neo's answer. If your array is an NSMutableArray, you can use the following line to get the first 20 items:

```
[myArray removeObjectsInRange:NSMakeRange(20, myArray.count - 20)];

```
You can extract the first 20 items, and re-assign your source array:

```
NSArray *myHugeArray = [[NSArray alloc] initWithItems:...] // An array with, say, 1000 items
NSArray *tmpArray = [myHugeArray objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 20)]];
[myHugeArray release];
myHugeArray = [tmpArray retain];

```