nickthedude nickthedude - 2 years ago 84
iOS Question

iPhone OS: How do I create an NSDate for a specific date?

Seems like a simple thing but I can't seem to find a way to do it.

It would be great to see a couple different methods.

Answer Source

@Chuck's answer is correct, and lead me to the following code. Thought I'd share:

NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:10];
[comps setMonth:10];
[comps setYear:2010];
self.timestamp = [[NSCalendar currentCalendar] dateFromComponents:comps];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download