iphone SDK CurrentDate Application
You can replace the above code with your original files and run to see date.
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]init] autorelease];
[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
0 comments:
Post a Comment
Share your thoughts here...