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

Solution 1:

@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];
NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:comps];

Solution 2:

You can use this

NSString *dateString = @"03-Sep-11";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"dd-MMM-yy";
NSDate *date = [dateFormatter dateFromString:dateString];

Hope this will help you out.