mirror of
https://github.com/samsonjs/CacheCreek.git
synced 2026-03-25 09:05:53 +00:00
Register and post notifications with an object
This commit is based on feedback that you should register UIApplication notification observers with the sharedApplication as the object.
This commit is contained in:
parent
f93527d8cc
commit
97d82f6cca
2 changed files with 4 additions and 4 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue