Share on Google+Share on Google+

NSLog array example

Advertisement
In this tutorial we will show you how to print the values of array using the NSLog function. Printing array values on the console is important debugging technique in iPhone application debugging.

The following code example explain it with running code example.

//
//  HelloArray.h
//  DataTypes
//
//

#import <Foundation/Foundation.h>  

@interface HelloArray : NSObject {   

    NSArray *arr; 

}

@end

The implementation of the class is as follows:

//
//  HelloArray.m
//  DataTypes
//
//

#import "HelloArray.h"

@implementation HelloArray

-(void) print{

     arr = [[NSArray alloc] initWithObjects:@"Me", @"Myself", @"I", @"and you", nil];

    NSLog(@"The content of arry is%@",arr);   

}

@end

The out put of the above example is:

The content of arry is(
    Me,
    Myself,
    I,
    "and you"
)
 

 

Advertisements

Posted on: July 29, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.