I wanted to get random numbers according to time. How do you get the current time in iOS Programming for the iPhone?
NSDate *now = [[NSDate alloc] init];
OR NSDate *now = [NSDate date];
an NSDate object by default will be initialised to the current date.
in addition to the existing answers:
gettimeofday
for high accuracy
or
CFAbsoluteTimeGetCurrent
if you want a fairly high level interface without an object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With