Skip to content

Commit 8eea6a5

Browse files
committed
Change some global constants to type properties to match the Darwin version
- `NSLocale.currentLocaleDidChangeNotification` - `OperationQueue.defaultMaxConcurrentOperationCount` - `Notification.Name.NSURLCredentialStorageChanged`
1 parent c41f353 commit 8eea6a5

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

Foundation/NSLocale.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ public func <(_ lhs: NSLocale.Key, _ rhs: NSLocale.Key) -> Bool {
245245
}
246246

247247

248-
249-
public let NSCurrentLocaleDidChangeNotification: String = "kCFLocaleCurrentLocaleDidChangeNotification"
248+
public extension NSLocale {
249+
public static let currentLocaleDidChangeNotification = NSNotification.Name(rawValue: "kCFLocaleCurrentLocaleDidChangeNotification")
250+
}
250251

251252

252253
extension CFLocale : _NSBridgeable, _SwiftBridgeable {

Foundation/NSOperation.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ open class BlockOperation: Operation {
201201
}
202202
}
203203

204-
public let NSOperationQueueDefaultMaxConcurrentOperationCount: Int = Int.max
204+
public extension OperationQueue {
205+
public static let defaultMaxConcurrentOperationCount: Int = Int.max
206+
}
205207

206208
internal struct _OperationList {
207209
var veryLow = [Operation]()
@@ -332,7 +334,7 @@ open class OperationQueue: NSObject {
332334
__concurrencyGate = DispatchSemaphore(value: 1)
333335
} else {
334336
attr = .concurrent
335-
if maxConcurrentOperationCount != NSOperationQueueDefaultMaxConcurrentOperationCount {
337+
if maxConcurrentOperationCount != OperationQueue.defaultMaxConcurrentOperationCount {
336338
__concurrencyGate = DispatchSemaphore(value:maxConcurrentOperationCount)
337339
}
338340
}
@@ -352,7 +354,7 @@ open class OperationQueue: NSObject {
352354
}
353355

354356
#if DEPLOYMENT_ENABLE_LIBDISPATCH
355-
internal init(_queue queue: DispatchQueue, maxConcurrentOperations: Int = NSOperationQueueDefaultMaxConcurrentOperationCount) {
357+
internal init(_queue queue: DispatchQueue, maxConcurrentOperations: Int = OperationQueue.defaultMaxConcurrentOperationCount) {
356358
__underlyingQueue = queue
357359
maxConcurrentOperationCount = maxConcurrentOperations
358360
super.init()
@@ -462,7 +464,7 @@ open class OperationQueue: NSObject {
462464
return count
463465
}
464466

465-
open var maxConcurrentOperationCount: Int = NSOperationQueueDefaultMaxConcurrentOperationCount
467+
open var maxConcurrentOperationCount: Int = OperationQueue.defaultMaxConcurrentOperationCount
466468

467469
internal var _suspended = false
468470
open var isSuspended: Bool {

Foundation/NSURLCredentialStorage.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ extension URLCredentialStorage {
9898
public func setDefaultCredential(_ credential: URLCredential, for protectionSpace: URLProtectionSpace, task: URLSessionTask) { NSUnimplemented() }
9999
}
100100

101-
/*!
102-
@const NSURLCredentialStorageChangedNotification
103-
@abstract This notification is sent on the main thread whenever
104-
the set of stored credentials changes.
105-
*/
106-
public let NSURLCredentialStorageChangedNotification: String = "" // NSUnimplemented
101+
public extension Notification.Name {
102+
/*!
103+
@const NSURLCredentialStorageChangedNotification
104+
@abstract This notification is sent on the main thread whenever
105+
the set of stored credentials changes.
106+
*/
107+
public static let NSURLCredentialStorageChanged = NSNotification.Name(rawValue: "") // NSUnimplemented
108+
}
107109

108110
/*
109111
* NSURLCredentialStorageRemoveSynchronizableCredentials - (NSNumber value)

TestFoundation/TestNSLocale.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class TestNSLocale : XCTestCase {
3939
}
4040

4141
func test_constants() {
42-
XCTAssertEqual(NSCurrentLocaleDidChangeNotification, "kCFLocaleCurrentLocaleDidChangeNotification",
43-
"\(NSCurrentLocaleDidChangeNotification) is not equal to kCFLocaleCurrentLocaleDidChangeNotification")
42+
XCTAssertEqual(NSLocale.currentLocaleDidChangeNotification.rawValue, "kCFLocaleCurrentLocaleDidChangeNotification",
43+
"\(NSLocale.currentLocaleDidChangeNotification.rawValue) is not equal to kCFLocaleCurrentLocaleDidChangeNotification")
4444

4545
XCTAssertEqual(NSLocale.Key.identifier.rawValue, "kCFLocaleIdentifierKey",
4646
"\(NSLocale.Key.identifier.rawValue) is not equal to kCFLocaleIdentifierKey")

0 commit comments

Comments
 (0)