diff --git a/MHPrettyDate/MHPrettyDate.h b/MHPrettyDate/MHPrettyDate.h index c96f565..2b5f2e0 100644 --- a/MHPrettyDate/MHPrettyDate.h +++ b/MHPrettyDate/MHPrettyDate.h @@ -89,6 +89,8 @@ typedef enum @interface MHPrettyDate : NSObject +@property (nonatomic, strong) NSDateFormatter *dateFormatter; + +(NSString*) prettyDateFromDate:(NSDate*) date withFormat:(MHPrettyDateFormat) dateFormat; +(NSString*) prettyDateFromDate:(NSDate*) date withFormat:(MHPrettyDateFormat) dateFormat withDateStyle:(NSDateFormatterStyle) dateStyle; +(NSString*) prettyDateFromDate:(NSDate*) date withFormat:(MHPrettyDateFormat) dateFormat withDateStyle:(NSDateFormatterStyle) dateStyle withTimeStyle:(NSDateFormatterStyle) timeStyle; diff --git a/MHPrettyDate/MHPrettyDate.m b/MHPrettyDate/MHPrettyDate.m index 48df1a2..88b1c6b 100644 --- a/MHPrettyDate/MHPrettyDate.m +++ b/MHPrettyDate/MHPrettyDate.m @@ -33,7 +33,6 @@ @interface MHPrettyDate() @property (readonly, nonatomic) NSDate* tomorrow; @property (readonly, nonatomic) NSDate* weekAgo; @property (readonly, nonatomic) NSCalendar* calendar; -@property (strong, nonatomic) NSDateFormatter* dateFormatter; @property (assign) MHPrettyDateFormat dateFormat; +(MHPrettyDate*) sharedInstance; @@ -233,7 +232,7 @@ +(NSString*) formattedStringForDate:(NSDate*) date withFormat:(MHPrettyDateForma +(NSString*) formattedStringForDate:(NSDate*) date withFormat:(MHPrettyDateFormat) dateFormat withDateStyle:(NSDateFormatterStyle) dateStyle withTimeStyle:(NSDateFormatterStyle) timeStyle { NSString* dateString; - NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + NSDateFormatter* formatter = [[self sharedInstance] dateFormatter]; if ([MHPrettyDate willMakePretty:date]) {