How do I remove all objects from an NSMutableArray?

GuybrushThreepwood picture GuybrushThreepwood · Oct 4, 2010 · Viewed 18.4k times · Source

I need to remove all objects from an NSMutableArray. I can't seem to do this by enumerating as the code crashes.

Can anyone tell me the best way to do this with a code example if possible?

Answer

Richard J. Ross III picture Richard J. Ross III · Oct 4, 2010

This should do the trick:

[myArray removeAllObjects];