React to changes coming in swift-corelibs-foundation
diff --git a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
index 38f4436..dd39e42 100644
--- a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
+++ b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
@@ -103,7 +103,7 @@
// been fulfilled, it would be more efficient to use a runloop
// source that can be signaled to wake up when an expectation is
// fulfilled.
- let runLoop = RunLoop.current()
+ let runLoop = RunLoop.current
let timeoutDate = Date(timeIntervalSinceNow: timeout)
repeat {
unfulfilledDescriptions = []
@@ -171,14 +171,14 @@
var observer: NSObjectProtocol? = nil
func removeObserver() {
if let observer = observer as? AnyObject {
- NotificationCenter.defaultCenter().removeObserver(observer)
+ NotificationCenter.default.removeObserver(observer)
}
}
weak var weakExpectation = expectation
observer = NotificationCenter
- .defaultCenter()
- .addObserverForName(Notification.Name(rawValue: notificationName),
+ .default
+ .addObserver(forName: Notification.Name(rawValue: notificationName),
object: objectToObserve,
queue: nil,
usingBlock: {
diff --git a/Tests/Functional/Asynchronous/Notifications/Expectations/main.swift b/Tests/Functional/Asynchronous/Notifications/Expectations/main.swift
index 6be7ba3..1345cc7 100644
--- a/Tests/Functional/Asynchronous/Notifications/Expectations/main.swift
+++ b/Tests/Functional/Asynchronous/Notifications/Expectations/main.swift
@@ -21,7 +21,7 @@
func test_observeNotificationWithName_passes() {
let notificationName = "notificationWithNameTest"
expectation(forNotification: notificationName, object:nil)
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: nil)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: nil)
waitForExpectations(timeout: 0.0)
}
@@ -31,7 +31,7 @@
let notificationName = "notificationWithNameAndObjectTest"
let dummyObject = NSObject()
expectation(forNotification: notificationName, object:dummyObject)
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
waitForExpectations(timeout: 0.0)
}
@@ -41,7 +41,7 @@
let notificationName = "notificationWithNameAndObject_expectNoObjectTest"
expectation(forNotification: notificationName, object:nil)
let dummyObject = NSObject()
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
waitForExpectations(timeout: 0.0)
}
@@ -50,7 +50,7 @@
// CHECK: Test Case 'NotificationExpectationsTestCase.test_observeNotificationWithIncorrectName_fails' failed \(\d+\.\d+ seconds\).
func test_observeNotificationWithIncorrectName_fails() {
expectation(forNotification: "expectedName", object: nil)
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "actualName"), object: nil)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "actualName"), object: nil)
waitForExpectations(timeout: 0.1)
}
@@ -62,7 +62,7 @@
let dummyObject: NSString = "dummyObject"
let anotherDummyObject = NSObject()
expectation(forNotification: notificationName, object: dummyObject)
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object:anotherDummyObject)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object:anotherDummyObject)
waitForExpectations(timeout: 0.1)
}
diff --git a/Tests/Functional/Asynchronous/Notifications/Handler/main.swift b/Tests/Functional/Asynchronous/Notifications/Handler/main.swift
index 2df8b63..7257f93 100644
--- a/Tests/Functional/Asynchronous/Notifications/Handler/main.swift
+++ b/Tests/Functional/Asynchronous/Notifications/Handler/main.swift
@@ -23,7 +23,7 @@
notification in
return false
})
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "returnFalse"), object: nil)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "returnFalse"), object: nil)
waitForExpectations(timeout: 0.1)
}
@@ -34,7 +34,7 @@
notification in
return true
})
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "returnTrue"), object: nil)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "returnTrue"), object: nil)
waitForExpectations(timeout: 0.1)
}
@@ -47,7 +47,7 @@
return true
})
waitForExpectations(timeout: 0.1, handler: nil)
- NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "note"), object: nil)
+ NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "note"), object: nil)
}
static var allTests = {