I want to count the number of items in a NSArray
and perform some operation based on that. I know it's not a big deal but I couldn't get it.
Please give some suggestions.
The main difference is that NSArray is for an ordered collection and NSSet is for an unordered collection. There are several articles out there that talk about the difference in speed between the two, like this one. If you're iterating through an unordered collection, NSSet is great.
An object representing a static ordered collection, for use instead of an Array constant in cases that require reference semantics.
arrays can't contain nil.
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];
That's really simple:
int arrayLength = array.count;
[yourNSArrayReference count]
; It is simple:=)
Very simple:-
[*your array name* count];
you have to just check
[array count];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With