diff --git a/CacheIsKingTests/CacheIsKingTests.swift b/CacheIsKingTests/CacheIsKingTests.swift index 7ff3a95..89a6ba2 100644 --- a/CacheIsKingTests/CacheIsKingTests.swift +++ b/CacheIsKingTests/CacheIsKingTests.swift @@ -160,7 +160,7 @@ class CacheIsKingTests: XCTestCase { XCTAssert(cache.count == 4) - NSNotificationCenter.defaultCenter().postNotificationName(UIApplicationDidReceiveMemoryWarningNotification, object: nil) + NSNotificationCenter.defaultCenter().postNotificationName(UIApplicationDidReceiveMemoryWarningNotification, object: UIApplication.sharedApplication()) XCTAssert(cache.count == 0) @@ -171,7 +171,7 @@ class CacheIsKingTests: XCTestCase { XCTAssert(cache.count == 4) - NSNotificationCenter.defaultCenter().postNotificationName(UIApplicationDidEnterBackgroundNotification, object: nil) + NSNotificationCenter.defaultCenter().postNotificationName(UIApplicationDidEnterBackgroundNotification, object: UIApplication.sharedApplication()) XCTAssert(cache.count == 0) } diff --git a/Source/KingCache.swift b/Source/KingCache.swift index a655ac2..faf43c7 100644 --- a/Source/KingCache.swift +++ b/Source/KingCache.swift @@ -33,13 +33,13 @@ public class KingCache { var notificationObserver = NSNotificationCenter.defaultCenter() .addObserverForName(UIApplicationDidReceiveMemoryWarningNotification, - object: nil, + object: UIApplication.sharedApplication(), queue: nil, usingBlock: removalBlock) notificationObservers.append(notificationObserver) notificationObserver = NSNotificationCenter.defaultCenter() .addObserverForName(UIApplicationDidEnterBackgroundNotification, - object: nil, + object: UIApplication.sharedApplication(), queue: nil, usingBlock: removalBlock) notificationObservers.append(notificationObserver)