Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Changed AnyObject to Any
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyKJohnson committed Nov 30, 2016
1 parent b616855 commit 7eb8fe9
Show file tree
Hide file tree
Showing 38 changed files with 159 additions and 156 deletions.
4 changes: 2 additions & 2 deletions Sources/Bridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol _OCKBridgable {

public protocol CKNumberValueType: CKRecordValue {}
extension CKNumberValueType where Self: _OCKBridgable, Self.ObjectType == NSNumber {
public var recordFieldDictionary: [String: AnyObject] {
public var recordFieldDictionary: [String: Any] {
return ["value": self.bridge()]
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ extension Double: _OCKBridgable {
}

extension NSDictionary {
public func bridge() -> [NSObject: AnyObject] {
public func bridge() -> [NSObject: Any] {
return self as [NSObject: AnyObject]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKAcceptSharesOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CKAcceptSharesOperation: CKOperation {
case .success(let dictionary):

// Process Records
if let resultsDictionary = dictionary["results"] as? [[String: AnyObject]] {
if let resultsDictionary = dictionary["results"] as? [[String: Any]] {
// Parse JSON into CKRecords
for resultDictionary in resultsDictionary {
if let shareMetadata = CKShareMetadata(dictionary: resultDictionary) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKAcceptSharesURLRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CKAcceptSharesURLRequest: CKURLRequest {
self.path = "accept"
self.operationType = CKOperationRequestType.records

var parameters: [String: AnyObject] = [:]
var parameters: [String: Any] = [:]

parameters["shortGUIDs"] = shortGUIDs.map({ (guid) -> NSDictionary in
return guid.dictionary.bridge()
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKAsset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CKAsset: NSObject {
self.fileURL = fileURL
}

init?(dictionary: [String: AnyObject]) {
init?(dictionary: [String: Any]) {

guard
let downloadURL = dictionary["downloadURL"] as? String,
Expand Down
10 changes: 5 additions & 5 deletions Sources/CKContainerConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public struct CKConfig {
self.containers = [container]
}

init?(dictionary: [String: AnyObject], workingDirectory: String?) {
guard let containerDictionaries = dictionary["containers"] as? [[String: AnyObject]] else {
init?(dictionary: [String: Any], workingDirectory: String?) {
guard let containerDictionaries = dictionary["containers"] as? [[String: Any]] else {
return nil
}

Expand All @@ -53,7 +53,7 @@ public struct CKConfig {

let jsonData = try NSData(contentsOfFile: path, options: [])

if let dictionary = try JSONSerialization.jsonObject(with: jsonData.bridge(), options: []) as? [String: AnyObject] {
if let dictionary = try JSONSerialization.jsonObject(with: jsonData.bridge(), options: []) as? [String: Any] {
self.init(dictionary: dictionary, workingDirectory: directory.path)!
} else {
throw CKConfigError.InvalidJSON
Expand Down Expand Up @@ -102,15 +102,15 @@ public struct CKContainerConfig {

let apnsEnvironment = CKEnvironment(rawValue: dictionary["apnsEnvironment"] as? String ?? "")

if let apiTokenAuthDictionary = dictionary["apiTokenAuth"] as? [String: AnyObject] {
if let apiTokenAuthDictionary = dictionary["apiTokenAuth"] as? [String: Any] {

if let apiToken = apiTokenAuthDictionary["apiToken"] as? String {
self.init(containerIdentifier: containerIdentifier, environment: environment, apiTokenAuth: apiToken, apnsEnvironment: apnsEnvironment)
} else {
return nil
}

} else if let serverToServerKeyAuthDictionary = dictionary["serverToServerKeyAuth"] as? [String: AnyObject] {
} else if let serverToServerKeyAuthDictionary = dictionary["serverToServerKeyAuth"] as? [String: Any] {
guard let keyID = serverToServerKeyAuthDictionary["keyID"] as? String, let privateKeyFile = serverToServerKeyAuthDictionary["privateKeyFile"] as? String else {
return nil
}
Expand Down
20 changes: 10 additions & 10 deletions Sources/CKDictionaryValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@
import Foundation
/*
protocol CKDictionaryValue {
func toObject() -> AnyObject?
func toObject() -> Any?
}

extension String: CKDictionaryValue {
func toObject() -> AnyObject? {
func toObject() -> Any? {
return self.bridge()
}
}

extension Int: CKDictionaryValue {
func toObject() -> AnyObject? {
func toObject() -> Any? {
return NSNumber(value: self)
}
}
extension Double: CKDictionaryValue {
func toObject() -> AnyObject? {
func toObject() -> Any? {
return NSNumber(value: self)
}
}

extension Float: CKDictionaryValue {
func toObject() -> AnyObject? {
func toObject() -> Any? {
return NSNumber(value: self)
}
}

extension Bool: CKDictionaryValue {
func toObject() -> AnyObject? {
func toObject() -> Any? {
return NSNumber(value: self)
}
}

extension Array: CKDictionaryValue {
func toObject() -> AnyObject? {
return self.bridge() as? AnyObject
func toObject() -> Any? {
return self.bridge() as? Any
}
}

extension Dictionary where Key: StringLiteralConvertible, Value: CKDictionaryValue {
func toObject() -> AnyObject? {
var dictionary: [String: AnyObject] = [:]
func toObject() -> Any? {
var dictionary: [String: Any] = [:]

for (key, value) in dictionary {
dictionary[key] = value.toObject()
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKDiscoverAllUserIdentitiesOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CKDiscoverAllUserIdentitiesOperation : CKOperation {
return
} else if let dictionary = dictionary {
// Process Records
if let userDictionaries = dictionary["users"] as? [[String: AnyObject]] {
if let userDictionaries = dictionary["users"] as? [[String: Any]] {
// Parse JSON into CKRecords
for userDictionary in userDictionaries {

Expand Down
4 changes: 2 additions & 2 deletions Sources/CKDiscoverUserIdentitiesOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CKDiscoverUserIdentitiesOperation : CKOperation {
return lookupInfo.dictionary
}

let request: [String: AnyObject] = ["lookupInfos": lookUpInfos.bridge() as AnyObject]
let request: [String: Any] = ["lookupInfos": lookUpInfos.bridge() as Any]

urlSessionTask = CKWebRequest(container: operationContainer).request(withURL: url, parameters: request) { (dictionary, error) in

Expand All @@ -58,7 +58,7 @@ public class CKDiscoverUserIdentitiesOperation : CKOperation {
return
} else if let dictionary = dictionary {
// Process Records
if let userDictionaries = dictionary["users"] as? [[String: AnyObject]] {
if let userDictionaries = dictionary["users"] as? [[String: Any]] {
// Parse JSON into CKRecords
for userDictionary in userDictionaries {

Expand Down
12 changes: 6 additions & 6 deletions Sources/CKFetchErrorDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

protocol CKFetchErrorDictionaryIdentifier {
init?(dictionary: [String: AnyObject])
init?(dictionary: [String: Any])

static var identifierKey: String { get }
}
Expand All @@ -29,7 +29,7 @@ struct CKErrorDictionary {
let redirectURL: String?
let uuid: String

init?(dictionary: [String: AnyObject]) {
init?(dictionary: [String: Any]) {

guard
let uuid = dictionary["uuid"] as? String,
Expand All @@ -53,7 +53,7 @@ struct CKErrorDictionary {

let errorCode = CKErrorCode.errorCode(serverError: serverErrorCode)!

var userInfo: NSErrorUserInfoType = [NSLocalizedDescriptionKey: reason.bridge() as AnyObject, "serverErrorCode": serverErrorCode.bridge() as AnyObject]
var userInfo: NSErrorUserInfoType = [NSLocalizedDescriptionKey: reason.bridge() as Any, "serverErrorCode": serverErrorCode.bridge() as Any]
if let redirectURL = redirectURL {
userInfo[CKErrorRedirectURLKey] = redirectURL.bridge()
}
Expand All @@ -74,10 +74,10 @@ struct CKFetchErrorDictionary<T: CKFetchErrorDictionaryIdentifier> {
let retryAfter: NSNumber?
let redirectURL: String?

init?(dictionary: [String: AnyObject]) {
init?(dictionary: [String: Any]) {

guard
let identifier = T(dictionary: dictionary[T.identifierKey] as? [String: AnyObject] ?? [:]),
let identifier = T(dictionary: dictionary[T.identifierKey] as? [String: Any] ?? [:]),
let reason = dictionary[CKRecordFetchErrorDictionary.reasonKey] as? String,
let serverErrorCode = dictionary[CKRecordFetchErrorDictionary.serverErrorCodeKey] as? String
else {
Expand All @@ -98,7 +98,7 @@ struct CKFetchErrorDictionary<T: CKFetchErrorDictionaryIdentifier> {

let errorCode = CKErrorCode.errorCode(serverError: serverErrorCode)!

var userInfo: NSErrorUserInfoType = [NSLocalizedDescriptionKey: reason.bridge() as AnyObject, "serverErrorCode": serverErrorCode.bridge() as AnyObject]
var userInfo: NSErrorUserInfoType = [NSLocalizedDescriptionKey: reason.bridge() as Any, "serverErrorCode": serverErrorCode.bridge() as Any]
if let redirectURL = redirectURL {
userInfo[CKErrorRedirectURLKey] = redirectURL.bridge()
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKFetchRecordZonesOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class CKFetchRecordZonesOperation : CKDatabaseOperation {
return
} else if let dictionary = dictionary {
// Process Records
if let zoneDictionaries = dictionary["zones"] as? [[String: AnyObject]] {
if let zoneDictionaries = dictionary["zones"] as? [[String: Any]] {
// Parse JSON into CKRecords
for zoneDictionary in zoneDictionaries {

Expand Down
8 changes: 4 additions & 4 deletions Sources/CKFetchRecordsOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CKFetchRecordsOperation: CKDatabaseOperation {

var isFetchCurrentUserOperation = false

var recordErrors: [String: AnyObject] = [:]
var recordErrors: [String: Any] = [:]

var shouldFetchAssetContent: Bool = false

Expand Down Expand Up @@ -43,8 +43,8 @@ public class CKFetchRecordsOperation: CKDatabaseOperation {
// Generate the CKOperation Web Service URL
let url = "\(operationURL)/records/\(CKRecordOperation.lookup)"

var request: [String: AnyObject] = [:]
let lookupRecords = recordIDs?.map { (recordID) -> [String: AnyObject] in
var request: [String: Any] = [:]
let lookupRecords = recordIDs?.map { (recordID) -> [String: Any] in
return ["recordName": recordID.recordName.bridge()]
}

Expand All @@ -63,7 +63,7 @@ public class CKFetchRecordsOperation: CKDatabaseOperation {
self.fetchRecordsCompletionBlock?(nil, error)
} else if let dictionary = dictionary {
// Process Records
if let recordsDictionary = dictionary["records"] as? [[String: AnyObject]] {
if let recordsDictionary = dictionary["records"] as? [[String: Any]] {
// Parse JSON into CKRecords
for (index,recordDictionary) in recordsDictionary.enumerated() {

Expand Down
4 changes: 2 additions & 2 deletions Sources/CKFetchSubscriptionsOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CKFetchSubscriptionsOperation : CKDatabaseOperation {

let url = "\(operationURL)/subscriptions/lookup"

var request: [String: AnyObject] = [:]
var request: [String: Any] = [:]
if let subscriptionIDs = subscriptionIDs {

request["subscriptions"] = subscriptionIDs.bridge()
Expand All @@ -51,7 +51,7 @@ public class CKFetchSubscriptionsOperation : CKDatabaseOperation {

} else if let dictionary = dictionary {

if let subscriptionsDictionary = dictionary["subscriptions"] as? [[String: AnyObject]] {
if let subscriptionsDictionary = dictionary["subscriptions"] as? [[String: Any]] {
// Parse JSON into CKRecords
var subscriptionsIDToSubscriptions: [String: CKSubscription] = [:]
var subscriptionErrorIDs: [String: NSError] = [:]
Expand Down
20 changes: 10 additions & 10 deletions Sources/CKModifyRecordZonesOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public class CKModifyRecordZonesOperation : CKDatabaseOperation {
*/
public var modifyRecordZonesCompletionBlock: (([CKRecordZone]?, [CKRecordZoneID]?, NSError?) -> Swift.Void)?

func zoneOperations() -> [[String: AnyObject]] {
func zoneOperations() -> [[String: Any]] {

var operationDictionaries: [[String: AnyObject]] = []
var operationDictionaries: [[String: Any]] = []
if let recordZonesToSave = recordZonesToSave {
let saveOperations = recordZonesToSave.map({ (zone) -> [String: AnyObject] in
let saveOperations = recordZonesToSave.map({ (zone) -> [String: Any] in

let operation: [String: AnyObject] = [
let operation: [String: Any] = [
"operationType": "create".bridge(),
"zone": ["zoneID".bridge(): zone.zoneID.dictionary].bridge() as AnyObject
"zone": ["zoneID".bridge(): zone.zoneID.dictionary].bridge() as Any
]

return operation
Expand All @@ -58,11 +58,11 @@ public class CKModifyRecordZonesOperation : CKDatabaseOperation {
}

if let recordZoneIDsToDelete = recordZoneIDsToDelete {
let deleteOperations = recordZoneIDsToDelete.map({ (zoneID) -> [String: AnyObject] in
let deleteOperations = recordZoneIDsToDelete.map({ (zoneID) -> [String: Any] in

let operation: [String: AnyObject] = [
let operation: [String: Any] = [
"operationType": "delete".bridge(),
"zone": ["zoneID".bridge(): zoneID.dictionary.bridge()].bridge() as AnyObject
"zone": ["zoneID".bridge(): zoneID.dictionary.bridge()].bridge() as Any
]

return operation
Expand All @@ -79,7 +79,7 @@ public class CKModifyRecordZonesOperation : CKDatabaseOperation {
let url = "\(databaseURL)/zones/modify"
let zoneOperations = self.zoneOperations().bridge()

let request: [String: AnyObject] = ["operations": zoneOperations]
let request: [String: Any] = ["operations": zoneOperations]

urlSessionTask = CKWebRequest(container: operationContainer).request(withURL: url, parameters: request) { (dictionary, error) in

Expand All @@ -94,7 +94,7 @@ public class CKModifyRecordZonesOperation : CKDatabaseOperation {
return
} else if let dictionary = dictionary {
// Process Records
if let zoneDictionaries = dictionary["zones"] as? [[String: AnyObject]] {
if let zoneDictionaries = dictionary["zones"] as? [[String: Any]] {
// Parse JSON into CKRecords
for zoneDictionary in zoneDictionaries {

Expand Down
6 changes: 3 additions & 3 deletions Sources/CKModifyRecordsOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct CKSubscriptionFetchErrorDictionary {

let redirectURL: String?

init?(dictionary: [String: AnyObject]) {
init?(dictionary: [String: Any]) {
guard
let subscriptionID = dictionary[CKSubscriptionFetchErrorDictionary.subscriptionIDKey] as? String,
let reason = dictionary[CKSubscriptionFetchErrorDictionary.reasonKey] as? String,
Expand Down Expand Up @@ -156,7 +156,7 @@ public class CKModifyRecordsOperation: CKDatabaseOperation {
case .success(let dictionary):

// Process Records
if let recordsDictionary = dictionary["records"] as? [[String: AnyObject]] {
if let recordsDictionary = dictionary["records"] as? [[String: Any]] {
// Parse JSON into CKRecords
for recordDictionary in recordsDictionary {

Expand Down Expand Up @@ -216,7 +216,7 @@ public class CKModifyRecordsOperation: CKDatabaseOperation {

} else if let dictionary = dictionary {
// Process Records
if let recordsDictionary = dictionary["records"] as? [[String: AnyObject]] {
if let recordsDictionary = dictionary["records"] as? [[String: Any]] {
// Parse JSON into CKRecords
for recordDictionary in recordsDictionary {

Expand Down
Loading

0 comments on commit 7eb8fe9

Please sign in to comment.