Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  NSDateFormatter *df = [[NSDateFormatter alloc] init];
  2.        [df setDateFormat:@"LLLL d, yyyy"];
  3.   NSDate *dateA = [df dateFromString:startDate.text];
  4.    NSDate *dateB= [df dateFromString:endDate.text];
  5.    NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
  6.         NSDateComponents *components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
  7.                                                    fromDate:dateA
  8.                                                      toDate:dateB
  9.                                                     options:0];
  10.   num.text  =[NSString stringWithFormat:@"%i", components.day];