Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

number of elements in NSMutableArray

How to know at runtime how many array elements are there in NSMutableArray?

like image 890
suse Avatar asked Feb 26 '10 09:02

suse


People also ask

What is difference between NSArray and NSMutableArray?

The primary difference between NSArray and NSMutableArray is that a mutable array can be changed/modified after it has been allocated and initialized, whereas an immutable array, NSArray , cannot.

What is NSMutableArray?

The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from NSArray . NSMutableArray is “toll-free bridged” with its Core Foundation counterpart, CFMutableArray .

How do I create an NSArray in Objective C?

Creating an Array Object The NSArray class contains a class method named arrayWithObjects that can be called upon to create a new array object and initialize it with elements. For example: NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil];


1 Answers

NSArray (NSMutableArray is a subclass of NSArray) has a count method.

Example:

NSUInteger arrayLength = [myMutableArray count];
like image 70
Jacob Relkin Avatar answered Nov 15 '22 22:11

Jacob Relkin