Skip to content

Commit

Permalink
S1Formatter should evict things from cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
ainopara committed Jan 7, 2017
1 parent 1ca3b30 commit b6a55f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Stage1st/S1Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions Stage1st/S1Global.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ + (S1Formatter *)sharedInstance
return myGlobalFormatter;
}

- (void)clearCache {
_dateCache = [[NSMutableDictionary alloc] init];
}

- (NSDateFormatter *)dateFormatter {
if (_dateFormatter == nil) {
_dateFormatter = [[NSDateFormatter alloc] init];
Expand Down
3 changes: 3 additions & 0 deletions Stage1st/TopicListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b6a55f0

Please sign in to comment.