Wednesday, April 25, 2012

Cocoa. Date and Time

This small program below detects the current date:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

     NSDate* today = [[NSDate alloc] init];
     NSLog(@"today is: %@", today);
    
    [today release];        
    [pool drain];
    return 0;
}
In the console you'll see:

run
[Switching to process 12401 local thread 0x3f03]
Running…
2010-03-06 17:05:45.217 DayOfToday[12401:a0f] today is: 2010-03-06 17:05:45 +0200

No comments:

Post a Comment