Nsarray is a static array that does not modify or add elements to the array. Therefore, nsarray alone is not enough. Nsmutablearray came into being to meet our needs.
Summary of common nsmutablearray Methods
Array |
Create an empty array |
+ (ID) arraywithcapacity: Size |
Create an array and specify the size. |
-(ID) initwithcapacity: Size |
Initializes a new allocated array and specifies the size. |
-(Void) addobject: OBJ |
Add object OBJ to the end of Array |
-(Void) insertobject: OBJ atindex: I |
Insert object OBJ to the position where the index is I |
-(Void) replaceobject: OBJ atindex: I |
Use OBJ to replace the element of the index in the array. |
-(Void) removeobject: OBJ |
Delete all objects with OBJ from the array |
-(Void) removeobjectatindex: I |
Delete the image with index I from the array |
-(Void) sortusingselector :( SEL) Selector |
Sort the Array Using the comparison method provided by Selector |