Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Makes sure to cache text even if the view isn't visible. Also caches …
Browse files Browse the repository at this point in the history
…text on DidEnterBackground notification.

Closes #427
  • Loading branch information
Ignacio Romero Zurbuchen committed Mar 30, 2016
1 parent 01b5925 commit f8b94bf
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1561,14 +1561,6 @@ - (void)slk_willShowOrHideTypeIndicatorView:(UIView <SLKTypingIndicatorProtocol>
}];
}

- (void)slk_willTerminateApplication:(NSNotification *)notification
{
// Caches the text before it's too late!
if (self.isViewVisible) {
[self slk_cacheTextView];
}
}


#pragma mark - KVO Events

Expand Down Expand Up @@ -2237,8 +2229,9 @@ - (void)slk_registerNotifications
[notificationCenter addObserver:self selector:@selector(slk_didShakeTextView:) name:SLKTextViewDidShakeNotification object:nil];

// Application notifications
[notificationCenter addObserver:self selector:@selector(slk_willTerminateApplication:) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_willTerminateApplication:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationDidEnterBackgroundNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
}

- (void)slk_unregisterNotifications
Expand Down Expand Up @@ -2270,6 +2263,7 @@ - (void)slk_unregisterNotifications

// Application notifications
[notificationCenter removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
[notificationCenter removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
}

Expand Down

0 comments on commit f8b94bf

Please sign in to comment.