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

Answer: 
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];

```
Suppose your NSArray is yourArray, do this

```
NSMutableArray *temp=[[NSMutableArray alloc]initWithArray:yourArray];
for(int i=0; i<20;i++){
    [temp addObject:[yourArray objectAtIndex:i]];
}
yourArray=[NSArray arrayWithArray:temp];

```