diff --git a/Stage1st/S1Global.h b/Stage1st/S1Global.h index 88c4075e..b7ebf421 100644 --- a/Stage1st/S1Global.h +++ b/Stage1st/S1Global.h @@ -19,6 +19,7 @@ @property (nonatomic, strong) NSDateFormatter *dateFormatter; @property (nonatomic, strong) NSMutableDictionary *dateCache; +- (void)clearCache; - (NSString *)headerForDate:(NSDate *)date; - (NSComparisonResult)compareDateString:(NSString *)dateString1 withDateString:(NSString *)dateString2; diff --git a/Stage1st/S1Global.m b/Stage1st/S1Global.m index 091b38cc..d62a4d2c 100644 --- a/Stage1st/S1Global.m +++ b/Stage1st/S1Global.m @@ -27,6 +27,10 @@ + (S1Formatter *)sharedInstance return myGlobalFormatter; } +- (void)clearCache { + _dateCache = [[NSMutableDictionary alloc] init]; +} + - (NSDateFormatter *)dateFormatter { if (_dateFormatter == nil) { _dateFormatter = [[NSDateFormatter alloc] init]; diff --git a/Stage1st/TopicListViewController.swift b/Stage1st/TopicListViewController.swift index 123a385c..60f21fc6 100644 --- a/Stage1st/TopicListViewController.swift +++ b/Stage1st/TopicListViewController.swift @@ -31,6 +31,9 @@ public enum TopicListPresentationType { extension S1TopicListViewController { + open override func didReceiveMemoryWarning() { + S1Formatter.sharedInstance().clearCache() + } func isPresentingDatabaseList(_ key: String) -> Bool { switch TopicListPresentationType(key: key) { case .favorite, .history: