iPhone SDK display current date | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

iPhone SDK display current date

Wednesday

 iphone SDK CurrentDate Application

                                                In this application used  to display current date on label by using Window based application. First create a window based application called CurrentDate. Creating a variable (mlabel), declared as IBOutlet andalso property is declared. 

The  CurrentDateAppDelegate.h  file look like this
#import<UIKit/UIKit.h>
@interfaceCurrentDateAppDelegate : NSObject <UIApplicationDelegate>
{
   UIWindow*window;
   IBOutletUILabel*mlabel;
   UIDatePicker*myDatePicker;
}
 @property(nonatomic,retain)IBOutletUIWindow*window;
@property(nonatomic,retain)IBOutletUILabel*mlabel;
 @end

The  CurrentDateAppDelegate.m file look like this


#import"CurrentDateAppDelegate.h"
@implementationCurrentDateAppDelegate
@synthesizewindow, mlabel;
-(void)applicationDidFinishLaunching:(UIApplication*)application

{
   [windowmakeKeyAndVisible];
   
   NSDateFormatter*dateFormatter =
   [[[NSDateFormatteralloc]initautorelease];
   [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
   [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
   NSDate*date =[NSDatedate];
   NSString*formattedDateString = [dateFormatterstringFromDate:date];
   NSLog(@"formattedDateStringfor locale %@: %@", [[dateFormatterlocale]localeIdentifier],formattedDateString);
   mlabel.text=[NSString stringWithFormat:@"%@",formattedDateString];
}
-(void)dealloc
{
   [windowrelease];
   [mlabelrelease];
   [superdealloc];
}
@end

You can replace the above code with your original  files and run to see date.

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets