The main classes related to time operations are:
NSDate
Nsdatformatter
Nscalendar
Nsdatecomponents
Also introduces a Timer object Nstimer
Used to describe a datetime, providing some basic time acquisition and comparison methods
+ (Instancetype) Date//Current date time + (Instancetype) Datewithtimeintervalsincenow: (nstimeinterval) seconds-( Nscomparisonresult) Compare: (NSDate *) anotherdate-(nstimeinterval) timeintervalsincedate: (NSDate *) anotherDate
NSDate object for string formatting
@property (copy) NSString *dateformat//Format-(NSString *) Stringfromdate: (NSDate *) date-(NSDate *) Datefromstring: ( NSString *) string
Calendar object, on top of the calendar object, to convert NSDate to Nsdatecomponents
+ (Nscalendar *) currentcalendar-(nsdatecomponents *) components: (nscalendarunit) unitflags fromdate: (nsdate*) date-( NSDate *) Datefromcomponents: (nsdatecomponents *) comps
Describes NSDate objects in a way that is used for objects
@property nsinteger year@property nsinteger month@property nsinteger day@property nsinteger hour@property NSInteger Minute@property Nsinteger Second ...
Nstimer is used to start a timer and perform the specified action at timed intervals.
The specified operation is specified with the SEL (method) object
Direct Start Timer + (Nstimer *) Scheduledtimerwithtimeinterval: (nstimeinterval) seconds target: (ID) Target selector: (SEL) Aselector UserInfo: (ID) UserInfo repeats: (BOOL) repeats//Create a timer that does not start directly + (Nstimer *) Timerwithtimeinterval: ( Nstimeinterval) seconds target: (ID) Target selector: (SEL) Aselector userInfo: (ID) UserInfo repeats: (BOOL) repeats
Other control methods of the timer:
-(void) fire//Start-(void) invalidate//disable
This article is from the "Teacheran" blog, make sure to keep this source http://annmeng.blog.51cto.com/3321237/1745755
Foundation Framework (7) Time operation