Here’s how to get the start of a day in Objective-C:

- (NSDate*)startOf:(NSDate*)date {
    int comps = NSYearCalendarUnit | 
        NSMonthCalendarUnit | NSDayCalendarUnit;
    NSDateComponents* dc = [[NSCalendar currentCalendar]
        components:comps fromDate:date];
    return [[NSCalendar currentCalendar] dateFromComponents:dc];
}

Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

iOS Developer in Sydney.

I have worked at places such as Google, Cochlear, News Corp, Fox Sports, NineMSN, FetchTV, Woolworths, and Westpac, among others. If you're looking for a good iOS developer, drop me a line!

Get in touch:
[email protected]
github.com/chrishulbert
linkedin
my resume



 Subscribe via RSS