NSLog Date example code


 

NSLog Date example code

In this example code I will show you how you can print the current date using the NSLog function.

In this example code I will show you how you can print the current date using the NSLog function.

In this following code we have create a variable to of NSDate class and then used the NSLog function to print the date on the console.

//
//  hellodate.h
//  DataTypes
//
// 

#import <Foundation/Foundation.h>  

@interface hellodate : NSObject {

    @public

    NSDate *today;

}

-(void) print; 

@end

The implementation class of hellodate is as follows:

//
//  hellodate.m
//  DataTypes
//
//

#import "hellodate.h"

@implementation hellodate

-(void) print{

    today= [NSDate date];

    NSLog(@"the current date is %@",today);

}

@end

 

Ads