Share on Google+Share on Google+

NSLog Date example code

Advertisement
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

 

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.