//
Rootviewcontroller.m
// time stamp is walking and shows Demo
//
Created by Dubai on 15/4/2.
Copyright (c) year Dubai. All rights reserved.
//
#import "RootViewController.h"
@interface rootviewcontroller ()
{
UILabel *labeltime;
Nstimer *timenow;
}
@end
@implementation Rootviewcontroller
-(void) Viewdidload {
[superviewdidload];
Additional setup after loading the view.
self. View. BackgroundColor = [uicolororangecolor];
labeltime = [[UILabelalloc] initwithframe: CGRectMake( Max, Max, )];
labeltime. BackgroundColor = [uicolorredcolor];
[Self. View addsubview:labeltime];
timenow = [ nstimer Scheduledtimerwithtimeinterval: 1.0f target: self selector: @ Selector (timerfunc) userinfo: nil repeats: yes ];
// Get system time
nsdate * senddate=[nsdatedate];
nsdateformatter *dateformatter=[[nsdateformatteralloc] Init ];
[DateformatterSetdateformat:@ "hh:mm"];
nsstring * locationstring=[dateformatter stringfromdate: senddate];
NSLog (@ "-------%@", locationstring);
// Get system time
Nscalendar * cal=[nscalendar currentcalendar];
nsuinteger unitflags=nsdaycalendarunit| Nsmonthcalendarunit| Nsyearcalendarunit;
nsdatecomponents * conponent= [cal components: unitflags fromdate: senddate];
nsinteger year=[conponent year];
Nsinteger month=[conponent month];
nsinteger day=[conponent Day];
nsstring * nsdatestring= [nsstring stringwithformat:@ "%4d year %2d Month %2d day ", Year,month,day];
NSLog (@ "+++++++++++++%@", nsdatestring);
}
-(void) Timerfunc
{
nsdateformatter *formatter = [[nsdateformatteralloc] init ];
[Formatter setdateformat:@ "Mm/dd/yy HH:mm:ss"];
nsstring *timestamp = [Formatter stringfromdate: [nsdate date]];
[labeltimesetText: timestamp]; // time in a changing statement
NSLog (@ "%@", timestamp);
}
-(void) didreceivememorywarning {
[superdidreceivememorywarning];
//Dispose of any resources, can be recreated.
}
/*
#pragma mark-navigation
In a storyboard-based application, you'll often want to do a little preparation before navigation
-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {
Get The new view controller using [Segue Destinationviewcontroller].
Pass the selected object to the new view controller.
}
*/
@end
IOS gets the current time and shows walking on the view