I want the current hours and minutes to be whole. So, if it's 3:16 now, I would like to get two integers: 3 and 16.
But it looks like it [NSDate date]will give the number of seconds since 1970, or it can give a string of the current time representation, but there is no easy way to get them as integers?
I see a message to get the current time , but take part in it NSDateComponentsand NSCalendar? It's too complicated ... all it takes is something like
NSDate *date = [NSDate date];
int hour = [date getHour];
Is there an easier way than using 3 classes NSDate, NSDateComponentsand NSCalendarto get the current hour as an integer or, as a rule, in Objective-C, we usually use the C language localtimeand tmto get the hour as an integer?
source
share