NSLog array example


 

NSLog array example

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.

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"
)
 

 

Ads