How do I remove all objects from an NSMutableArray?

Viewed 19655

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?

5 Answers

1.Create instance of NSMutableArray in .h file

@property (strong, nonatomic) NSMutableArray* arrayEmployee;

2.@synthesize in .m file

@synthesize arrayEmployee;

3.Remove all objects from an NSMutableArray

[self.arrayEmployee removeAllObjects];

In Swift 3:

yourArry.removeAllObjects()
  // In Swift     

 arrayName.removeAllObjects()
Related