Home Tutorial Iphone Examples NSArray Count Example

 
 

Share on Google+Share on Google+
NSArray Count Example
Posted on: October 6, 2010 at 12:00 AM
Advertisement
In the example, we are going to count the number of elements in an array in objective c programming.In Objective C language, Count is a primitive instance method that returns the number of objects available in an array.

NSArray Count Example

In the example, we are going to count the number of elements in an array in objective c programming.

In Objective C language, Count is a primitive instance method that returns the number of objects available in an array.

Syntax of count method in objective c language
- (NSUInteger)count

a simple example:

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];

NSArray *marray;
marray = [NSArray arrayWithObject:@"1"];

int mcount =[marray count];

NSLog (@"array = %i", mcount);

if (mcount == 0)
{
NSLog(@"Array is ZERO");
}
else
{
NSLog(@"Array is ONE");
}
return;

}

the output is:
2010-10-05 15:26:05.700 method[1117:207] array = 1
2010-10-05 15:26:05.728 method[1117:207] Array is ONE

Advertisement

Related Tags for NSArray Count Example:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 6, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com