Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

dateFromString: calls getObjectValue:forString:range:error:

By: a guest on Aug 20th, 2012  |  syntax: Objective C  |  size: 0.79 KB  |  views: 37  |  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. #import <Foundation/Foundation.h>
  2.  
  3. @interface NSDateFormatterLogger : NSDateFormatter
  4.  
  5. @end
  6.  
  7. @implementation NSDateFormatterLogger
  8.  
  9. - (BOOL)getObjectValue:(__autoreleasing id *)obj forString:(NSString *)string range:(NSRange *)rangep error:(NSError *__autoreleasing *)error
  10. {
  11.     NSLog(@"%@ called", NSStringFromSelector(_cmd));
  12.     return [super getObjectValue:obj forString:string range:rangep error:error];
  13. }
  14.  
  15. @end
  16.  
  17. int main(int argc, const char * argv[])
  18. {
  19.  
  20.     @autoreleasepool {
  21.        
  22.         NSString * dateString = @"2012-08-16T16:20:52.619000+00:00";
  23.        
  24.         NSDateFormatterLogger *df = [NSDateFormatterLogger new];
  25.         [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"];
  26.         NSLog(@"%@", [df dateFromString:dateString]);
  27.        
  28.     }
  29.     return 0;
  30. }
clone this paste RAW Paste Data