diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m index 34ea4e2eb..a77549a58 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "DebugUIContacts.h" @@ -1164,7 +1164,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(count > 0); OWSAssert(batchCompletionHandler); - DDLogDebug(@"createRandomContactsBatch: %zd", count); + DDLogDebug(@"createRandomContactsBatch: %zu", count); CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts]; if (status == CNAuthorizationStatusDenied || status == CNAuthorizationStatusRestricted) { @@ -1219,7 +1219,7 @@ NS_ASSUME_NONNULL_BEGIN } } - DDLogError(@"Saving fake contacts: %zd", contacts.count); + DDLogError(@"Saving fake contacts: %zu", contacts.count); NSError *saveError = nil; if (![store executeSaveRequest:request error:&saveError]) { diff --git a/SignalMessaging/utils/LRUCache.swift b/SignalMessaging/utils/LRUCache.swift index 9a252dcee..002c8d1a6 100644 --- a/SignalMessaging/utils/LRUCache.swift +++ b/SignalMessaging/utils/LRUCache.swift @@ -43,12 +43,22 @@ public class LRUCache { selector: #selector(didReceiveMemoryWarning), name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil) + NotificationCenter.default.addObserver(self, + selector: #selector(didEnterBackground), + name: NSNotification.Name.OWSApplicationDidEnterBackground, + object: nil) } deinit { NotificationCenter.default.removeObserver(self) } + @objc func didEnterBackground() { + SwiftAssertIsOnMainThread(#function) + + clear() + } + @objc func didReceiveMemoryWarning() { SwiftAssertIsOnMainThread(#function)