Initial commit to update to Swift 3.0 syntax.
Project: http://git-wip-us.apache.org/repos/asf/usergrid-swift/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid-swift/commit/b022377f Tree: http://git-wip-us.apache.org/repos/asf/usergrid-swift/tree/b022377f Diff: http://git-wip-us.apache.org/repos/asf/usergrid-swift/diff/b022377f Branch: refs/heads/master Commit: b022377fe3929c4759277797114d07f9abb97d32 Parents: 2202326 Author: Robert Walsh <[email protected]> Authored: Wed Sep 14 09:17:22 2016 -0500 Committer: Robert Walsh <[email protected]> Committed: Wed Sep 14 09:17:22 2016 -0500 ---------------------------------------------------------------------- .../ActivityFeed.xcodeproj/project.pbxproj | 118 +++++++++- .../contents.xcworkspacedata | 3 + .../ActivityFeed/Source/ActivityEntity.swift | 8 +- Samples/ActivityFeed/Source/AppDelegate.swift | 12 +- .../Source/FollowViewController.swift | 12 +- Samples/ActivityFeed/Source/FormTextField.swift | 18 +- .../Source/LoginViewController.swift | 24 +- .../Source/MessageTableViewCell.swift | 42 ++-- .../ActivityFeed/Source/MessageTextView.swift | 12 +- .../Source/MessageViewController.swift | 129 ++++++----- .../Source/RegisterViewController.swift | 20 +- .../ActivityFeed/Source/UsergridManager.swift | 22 +- .../Source/ViewControllerExtensions.swift | 8 +- .../InterfaceController.swift | 22 +- Samples/Push/Push.xcodeproj/project.pbxproj | 3 + Samples/Push/Source/AppDelegate.swift | 8 +- Samples/Push/Source/UsergridManager.swift | 8 +- Samples/Push/Source/ViewController.swift | 4 +- Source/Usergrid.swift | 87 ++++---- Source/UsergridAsset.swift | 63 +++--- Source/UsergridAssetRequestWrapper.swift | 14 +- Source/UsergridAuth.swift | 52 ++--- Source/UsergridClient.swift | 220 +++++++++---------- Source/UsergridClientConfig.swift | 28 +-- Source/UsergridDevice.swift | 48 ++-- Source/UsergridEntity.swift | 176 +++++++-------- Source/UsergridEnums.swift | 210 +++++++++--------- Source/UsergridExtensions.swift | 24 +- Source/UsergridFileMetaData.swift | 30 +-- Source/UsergridKeychainHelpers.swift | 84 +++---- Source/UsergridQuery.swift | 158 ++++++++----- Source/UsergridRequest.swift | 83 +++---- Source/UsergridRequestManager.swift | 78 +++---- Source/UsergridResponse.swift | 22 +- Source/UsergridResponseError.swift | 6 +- Source/UsergridSessionDelegate.swift | 42 ++-- Source/UsergridUser.swift | 123 +++++------ Tests/ASSET_Tests.swift | 61 ++--- Tests/AUTH_Tests.swift | 26 +-- Tests/CONNECTION_Tests.swift | 24 +- Tests/ClientCreationTests.swift | 6 +- Tests/GET_Tests.swift | 30 +-- Tests/PUT_Tests.swift | 28 +-- Tests/User_Tests.swift | 82 +++---- UsergridSDK.xcodeproj/project.pbxproj | 40 +++- .../xcschemes/UsergridSDK OSX.xcscheme | 2 +- .../xcschemes/UsergridSDK iOS.xcscheme | 2 +- .../xcschemes/UsergridSDK tvOS.xcscheme | 2 +- .../xcschemes/UsergridSDK watchOS.xcscheme | 2 +- .../xcschemes/UsergridSDK_OSX_Tests.xcscheme | 2 +- .../xcschemes/UsergridSDK_TVOS_Tests.xcscheme | 2 +- .../xcschemes/UsergridSDK_iOS_Tests.xcscheme | 2 +- 52 files changed, 1276 insertions(+), 1056 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj b/Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj index 215ca87..61a984b 100644 --- a/Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj +++ b/Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 587A839139502BE0380CD1DA /* Pods_ActivityFeed.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 383F79CDBA14ABFBFE0D157C /* Pods_ActivityFeed.framework */; }; 634855401C726AE9005FE016 /* UsergridSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634855331C726AD3005FE016 /* UsergridSDK.framework */; }; 634855411C726AE9005FE016 /* UsergridSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 634855331C726AD3005FE016 /* UsergridSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 634855451C726AF7005FE016 /* UsergridSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634855351C726AD3005FE016 /* UsergridSDK.framework */; }; @@ -164,6 +165,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 27CE17FF2D4FC59A741243ED /* Pods-ActivityFeed.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ActivityFeed.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ActivityFeed/Pods-ActivityFeed.debug.xcconfig"; sourceTree = "<group>"; }; + 383F79CDBA14ABFBFE0D157C /* Pods_ActivityFeed.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ActivityFeed.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 5F7C629490712A1E96D1C945 /* Pods-ActivityFeed.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ActivityFeed.release.xcconfig"; path = "Pods/Target Support Files/Pods-ActivityFeed/Pods-ActivityFeed.release.xcconfig"; sourceTree = "<group>"; }; 634855281C726AD3005FE016 /* UsergridSDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = UsergridSDK.xcodeproj; path = ../../UsergridSDK.xcodeproj; sourceTree = "<group>"; }; 6348D95B1C4EAC0B005C978C /* WatchSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WatchSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6348D95E1C4EAC0B005C978C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = "<group>"; }; @@ -206,12 +210,28 @@ buildActionMask = 2147483647; files = ( 634855401C726AE9005FE016 /* UsergridSDK.framework in Frameworks */, + 587A839139502BE0380CD1DA /* Pods_ActivityFeed.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A56E0389E87D6C6C996BF007 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2112A2F4682490176F99F6BA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 383F79CDBA14ABFBFE0D157C /* Pods_ActivityFeed.framework */, + ); + name = Frameworks; + sourceTree = "<group>"; + }; 634855291C726AD3005FE016 /* Products */ = { isa = PBXGroup; children = ( @@ -255,6 +275,8 @@ 6348D95C1C4EAC0B005C978C /* WatchSample */, 6348D96B1C4EAC0B005C978C /* WatchSample Extension */, 6355FEC21BFE4FC600E07170 /* Products */, + CDFE621065D6B589E1F28562 /* Pods */, + 2112A2F4682490176F99F6BA /* Frameworks */, ); sourceTree = "<group>"; }; @@ -322,6 +344,15 @@ name = Storyboards; sourceTree = "<group>"; }; + CDFE621065D6B589E1F28562 /* Pods */ = { + isa = PBXGroup; + children = ( + 27CE17FF2D4FC59A741243ED /* Pods-ActivityFeed.debug.xcconfig */, + 5F7C629490712A1E96D1C945 /* Pods-ActivityFeed.release.xcconfig */, + ); + name = Pods; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -331,6 +362,7 @@ buildPhases = ( 6348D9591C4EAC0B005C978C /* Resources */, 6348D97B1C4EAC0C005C978C /* Embed App Extensions */, + A56E0389E87D6C6C996BF007 /* Frameworks */, ); buildRules = ( ); @@ -365,11 +397,14 @@ isa = PBXNativeTarget; buildConfigurationList = 6355FED31BFE4FC600E07170 /* Build configuration list for PBXNativeTarget "ActivityFeed" */; buildPhases = ( + 472DB0E2A40503BB734CFCDA /* [CP] Check Pods Manifest.lock */, 6355FEBD1BFE4FC600E07170 /* Sources */, 6355FEBE1BFE4FC600E07170 /* Frameworks */, 6355FEBF1BFE4FC600E07170 /* Resources */, 6348D97D1C4EAC0C005C978C /* Embed Watch Content */, 634855441C726AE9005FE016 /* Embed Frameworks */, + A3199695972495C1CCD1CB10 /* [CP] Embed Pods Frameworks */, + 91D9D0F42FF78FB16CE0E42F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -389,17 +424,20 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Apigee Inc."; TargetAttributes = { 6348D95A1C4EAC0B005C978C = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; }; 6348D9661C4EAC0B005C978C = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; }; 6355FEC01BFE4FC600E07170 = { CreatedOnToolsVersion = 7.1.1; + LastSwiftMigration = 0800; }; }; }; @@ -511,6 +549,54 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 472DB0E2A40503BB734CFCDA /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 91D9D0F42FF78FB16CE0E42F /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ActivityFeed/Pods-ActivityFeed-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + A3199695972495C1CCD1CB10 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ActivityFeed/Pods-ActivityFeed-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 6348D9631C4EAC0B005C978C /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -597,43 +683,45 @@ 6348D9761C4EAC0C005C978C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; IBSC_MODULE = WatchSample_Extension; INFOPLIST_FILE = WatchSample/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.activityfeed.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Debug; }; 6348D9771C4EAC0C005C978C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; IBSC_MODULE = WatchSample_Extension; INFOPLIST_FILE = WatchSample/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.activityfeed.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Release; }; 6348D9781C4EAC0C005C978C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "WatchSample Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; @@ -641,15 +729,16 @@ PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Debug; }; 6348D9791C4EAC0C005C978C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "WatchSample Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; @@ -657,8 +746,10 @@ PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Release; }; @@ -747,12 +838,13 @@ }; 6355FED41BFE4FC600E07170 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 27CE17FF2D4FC59A741243ED /* Pods-ActivityFeed.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; INFOPLIST_FILE = Source/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.activityfeed; @@ -761,17 +853,19 @@ SWIFT_INSTALL_OBJC_HEADER = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; 6355FED51BFE4FC600E07170 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5F7C629490712A1E96D1C945 /* Pods-ActivityFeed.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; INFOPLIST_FILE = Source/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.activityfeed; @@ -779,6 +873,8 @@ PROVISIONING_PROFILE = ""; SWIFT_INSTALL_OBJC_HEADER = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/ActivityFeed.xcworkspace/contents.xcworkspacedata ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/ActivityFeed.xcworkspace/contents.xcworkspacedata b/Samples/ActivityFeed/ActivityFeed.xcworkspace/contents.xcworkspacedata index 1344aa3..43deff1 100644 --- a/Samples/ActivityFeed/ActivityFeed.xcworkspace/contents.xcworkspacedata +++ b/Samples/ActivityFeed/ActivityFeed.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ <FileRef location = "group:ActivityFeed.xcodeproj"> </FileRef> + <FileRef + location = "group:Pods/Pods.xcodeproj"> + </FileRef> </Workspace> http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/ActivityEntity.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/ActivityEntity.swift b/Samples/ActivityFeed/Source/ActivityEntity.swift index 5ddcf12..4cea1fc 100644 --- a/Samples/ActivityFeed/Source/ActivityEntity.swift +++ b/Samples/ActivityFeed/Source/ActivityEntity.swift @@ -45,7 +45,7 @@ public class ActivityEntity: UsergridEntity { UsergridEntity.mapCustomType("activity", toSubclass: ActivityEntity.self) } - required public init(type: String, name: String?, propertyDict: [String : AnyObject]?) { + required public init(type: String, name: String?, propertyDict: [String : Any]?) { super.init(type: type, name: name, propertyDict: propertyDict) } @@ -53,8 +53,8 @@ public class ActivityEntity: UsergridEntity { super.init(coder: aDecoder) } - public override func encodeWithCoder(aCoder: NSCoder) { - super.encodeWithCoder(aCoder) + open override func encode(with aCoder: NSCoder) { + super.encode(with:aCoder) } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/AppDelegate.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/AppDelegate.swift b/Samples/ActivityFeed/Source/AppDelegate.swift index cca5c41..35d69c0 100644 --- a/Samples/ActivityFeed/Source/AppDelegate.swift +++ b/Samples/ActivityFeed/Source/AppDelegate.swift @@ -34,10 +34,10 @@ import UsergridSDK var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { - UINavigationBar.appearance().tintColor = UIColor.whiteColor() - application.registerUserNotificationSettings(UIUserNotificationSettings( forTypes: [.Alert, .Badge, .Sound], categories: nil)) + UINavigationBar.appearance().tintColor = UIColor.white + application.registerUserNotificationSettings(UIUserNotificationSettings( types: [.alert, .badge, .sound], categories: nil)) application.registerForRemoteNotifications() // Initialize the Usergrid shared instance. @@ -48,17 +48,17 @@ import UsergridSDK if Usergrid.currentUser != nil { let rootViewController = self.window!.rootViewController as! UINavigationController let loginViewController = rootViewController.viewControllers.first! - loginViewController.performSegueWithIdentifier("loginSuccessNonAnimatedSegue", sender: loginViewController) + loginViewController.performSegue(withIdentifier: "loginSuccessNonAnimatedSegue", sender: loginViewController) } return true } - func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { + func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Usergrid.applyPushToken(deviceToken, notifierID: UsergridManager.NOTIFIER_ID, completion: nil) } - func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { + func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { print("Application failed to register for remote notifications") } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/FollowViewController.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/FollowViewController.swift b/Samples/ActivityFeed/Source/FollowViewController.swift index 6362cdb..70d4fb7 100644 --- a/Samples/ActivityFeed/Source/FollowViewController.swift +++ b/Samples/ActivityFeed/Source/FollowViewController.swift @@ -32,19 +32,19 @@ class FollowViewController : UIViewController { @IBOutlet weak var usernameTextField: UITextField! - @IBAction func addFollowerButtonTouched(sender:AnyObject?) { - guard let username = usernameTextField.text where !username.isEmpty + @IBAction func addFollowerButtonTouched(_ sender:AnyObject?) { + guard let username = usernameTextField.text, !username.isEmpty else { - self.showAlert(title: "Follow failed.", message: "Please enter a valid username.") + self.showAlert("Follow failed.", message: "Please enter a valid username.") return } UsergridManager.followUser(username) { (response) -> Void in if response.ok { - self.performSegueWithIdentifier("unwindToChatSegue", sender: self) + self.performSegue(withIdentifier: "unwindToChatSegue", sender: self) } else { - self.showAlert(title: "Follow failed.", message: "No user with the username \"\(username)\" found.") + self.showAlert("Follow failed.", message: "No user with the username \"\(username)\" found.") } } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/FormTextField.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/FormTextField.swift b/Samples/ActivityFeed/Source/FormTextField.swift index fbb9bd6..961098e 100644 --- a/Samples/ActivityFeed/Source/FormTextField.swift +++ b/Samples/ActivityFeed/Source/FormTextField.swift @@ -43,29 +43,29 @@ import UIKit } func setUp() { - addTarget(self, action: #selector(FormTextField.actionKeyboardButtonTapped(_:)), forControlEvents: .EditingDidEndOnExit) + addTarget(self, action: #selector(FormTextField.actionKeyboardButtonTapped(_:)), for: .editingDidEndOnExit) } - func actionKeyboardButtonTapped(sender: UITextField) { + func actionKeyboardButtonTapped(_ sender: UITextField) { switch nextResponderField { case let button as UIButton: - if button.enabled { - button.sendActionsForControlEvents(.TouchUpInside) + if button.isEnabled { + button.sendActions(for: .touchUpInside) } else { resignFirstResponder() } - case .Some(let responder): + case .some(let responder): responder.becomeFirstResponder() default: resignFirstResponder() } } - override func textRectForBounds(bounds: CGRect) -> CGRect { - return CGRectInset(bounds, inset, 0) + override func textRect(forBounds bounds: CGRect) -> CGRect { + return bounds.insetBy(dx: inset, dy: 0) } - override func editingRectForBounds(bounds: CGRect) -> CGRect { - return textRectForBounds(bounds) + override func editingRect(forBounds bounds: CGRect) -> CGRect { + return textRect(forBounds: bounds) } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/LoginViewController.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/LoginViewController.swift b/Samples/ActivityFeed/Source/LoginViewController.swift index 0e6c0fa..7a8e261 100644 --- a/Samples/ActivityFeed/Source/LoginViewController.swift +++ b/Samples/ActivityFeed/Source/LoginViewController.swift @@ -33,45 +33,45 @@ class LoginViewController: UIViewController { @IBOutlet weak var usernameTextField: UITextField! @IBOutlet weak var passwordTextField: UITextField! - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.passwordTextField.text = nil } - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { Usergrid.logoutCurrentUser() super.viewDidAppear(animated) } - override func viewWillDisappear(animated: Bool) { + override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) self.view.endEditing(true) } - @IBAction func loginButtonTouched(sender: AnyObject) { - guard let username = usernameTextField.text where !username.isEmpty, - let password = passwordTextField.text where !password.isEmpty + @IBAction func loginButtonTouched(_ sender: AnyObject) { + guard let username = usernameTextField.text, !username.isEmpty, + let password = passwordTextField.text, !password.isEmpty else { - self.showAlert(title: "Error Authenticating User", message: "Username and password must not be empty.") + self.showAlert("Error Authenticating User", message: "Username and password must not be empty.") return; } self.loginUser(username, password: password) } - func loginUser(username:String, password:String) { + func loginUser(_ username:String, password:String) { UsergridManager.loginUser(username,password: password) { (auth, user, error) -> Void in if let authErrorDescription = error { - self.showAlert(title: "Error Authenticating User", message: authErrorDescription.errorDescription) + self.showAlert("Error Authenticating User", message: authErrorDescription.errorDescription) } else if let authenticatedUser = user { - self.showAlert(title: "Authenticated User Successful", message: "User description: \n \(authenticatedUser.stringValue)") { (action) -> Void in - self.performSegueWithIdentifier("loginSuccessSegue", sender: self) + self.showAlert("Authenticated User Successful", message: "User description: \n \(authenticatedUser.stringValue)") { (action) -> Void in + self.performSegue(withIdentifier: "loginSuccessSegue", sender: self) } } } } - @IBAction func unwind(segue: UIStoryboardSegue) { + @IBAction func unwind(_ segue: UIStoryboardSegue) { // Used for unwind segues back to this view controller. } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/MessageTableViewCell.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/MessageTableViewCell.swift b/Samples/ActivityFeed/Source/MessageTableViewCell.swift index a77abd8..8e018d3 100644 --- a/Samples/ActivityFeed/Source/MessageTableViewCell.swift +++ b/Samples/ActivityFeed/Source/MessageTableViewCell.swift @@ -32,7 +32,7 @@ public class MessageTableViewCell : UITableViewCell { var titleLabel : UILabel var bodyLabel : UILabel var thumbnailView : UIImageView - var indexPath : NSIndexPath? + var indexPath : IndexPath? public static let kMessageTableViewCellMinimumHeight: CGFloat = 50.0; public static let kMessageTableViewCellAvatarHeight: CGFloat = 30.0; @@ -48,8 +48,8 @@ public class MessageTableViewCell : UITableViewCell { super.init(style: style, reuseIdentifier: reuseIdentifier) - self.selectionStyle = UITableViewCellSelectionStyle.None - self.backgroundColor = UIColor.whiteColor() + self.selectionStyle = UITableViewCellSelectionStyle.none + self.backgroundColor = UIColor.white self.configureSubviews() } @@ -58,30 +58,30 @@ public class MessageTableViewCell : UITableViewCell { } override public func prepareForReuse() { - self.selectionStyle = UITableViewCellSelectionStyle.None - self.titleLabel.font = UIFont.boldSystemFontOfSize(MessageTableViewCell.defaultFontSize) - self.bodyLabel.font = UIFont.boldSystemFontOfSize(13) + self.selectionStyle = UITableViewCellSelectionStyle.none + self.titleLabel.font = UIFont.boldSystemFont(ofSize: MessageTableViewCell.defaultFontSize) + self.bodyLabel.font = UIFont.boldSystemFont(ofSize: 13) self.titleLabel.text = "" self.bodyLabel.text = "" } func configureSubviews() { self.titleLabel.translatesAutoresizingMaskIntoConstraints = false - self.titleLabel.backgroundColor = UIColor.clearColor() - self.titleLabel.userInteractionEnabled = false + self.titleLabel.backgroundColor = UIColor.clear + self.titleLabel.isUserInteractionEnabled = false self.titleLabel.numberOfLines = 0 - self.titleLabel.textColor = UIColor.grayColor() - self.titleLabel.font = UIFont.boldSystemFontOfSize(MessageTableViewCell.defaultFontSize) + self.titleLabel.textColor = UIColor.gray + self.titleLabel.font = UIFont.boldSystemFont(ofSize: MessageTableViewCell.defaultFontSize) self.bodyLabel.translatesAutoresizingMaskIntoConstraints = false - self.bodyLabel.backgroundColor = UIColor.clearColor() - self.bodyLabel.userInteractionEnabled = false + self.bodyLabel.backgroundColor = UIColor.clear + self.bodyLabel.isUserInteractionEnabled = false self.bodyLabel.numberOfLines = 0 - self.bodyLabel.textColor = UIColor.grayColor() - self.bodyLabel.font = UIFont.boldSystemFontOfSize(13) + self.bodyLabel.textColor = UIColor.gray + self.bodyLabel.font = UIFont.boldSystemFont(ofSize: 13) self.thumbnailView.translatesAutoresizingMaskIntoConstraints = false - self.thumbnailView.userInteractionEnabled = false + self.thumbnailView.isUserInteractionEnabled = false self.thumbnailView.backgroundColor = UIColor(white: 0.9, alpha: 1.0) self.thumbnailView.layer.cornerRadius = 15 self.thumbnailView.layer.masksToBounds = true @@ -90,12 +90,12 @@ public class MessageTableViewCell : UITableViewCell { self.contentView.addSubview(self.titleLabel) self.contentView.addSubview(self.bodyLabel) - let views = ["thumbnailView":self.thumbnailView, "titleLabel":self.titleLabel, "bodyLabel":self.bodyLabel] + let views = ["thumbnailView":self.thumbnailView, "titleLabel":self.titleLabel, "bodyLabel":self.bodyLabel] as [String : Any] let metrics = ["thumbSize":MessageTableViewCell.kMessageTableViewCellAvatarHeight, "padding":15, "right":10, "left":5] - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-left-[thumbnailView(thumbSize)]-right-[titleLabel(>=0)]-right-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-left-[thumbnailView(thumbSize)]-right-[bodyLabel(>=0)]-right-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-right-[titleLabel(20)]-left-[bodyLabel(>=0@999)]-left-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-right-[thumbnailView(thumbSize)]-(>=0)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) + self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[thumbnailView(thumbSize)]-right-[titleLabel(>=0)]-right-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) + self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[thumbnailView(thumbSize)]-right-[bodyLabel(>=0)]-right-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) + self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-right-[titleLabel(20)]-left-[bodyLabel(>=0@999)]-left-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) + self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-right-[thumbnailView(thumbSize)]-(>=0)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views)) } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/MessageTextView.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/MessageTextView.swift b/Samples/ActivityFeed/Source/MessageTextView.swift index 135372e..b8bb464 100644 --- a/Samples/ActivityFeed/Source/MessageTextView.swift +++ b/Samples/ActivityFeed/Source/MessageTextView.swift @@ -28,12 +28,12 @@ import Foundation import SlackTextViewController class MessageTextView : SLKTextView { - override func willMoveToSuperview(newSuperview: UIView?) { - super.willMoveToSuperview(newSuperview) - self.backgroundColor = UIColor.whiteColor() - self.placeholderColor = UIColor.lightGrayColor() + override func willMove(toSuperview newSuperview: UIView?) { + super.willMove(toSuperview: newSuperview) + self.backgroundColor = UIColor.white + self.placeholderColor = UIColor.lightGray self.placeholder = "Message" - self.pastableMediaTypes = .None - self.layer.borderColor = UIColor(red: 217/255, green: 217/255, blue: 217/255, alpha: 1.0).CGColor + self.pastableMediaTypes = [] + self.layer.borderColor = UIColor(red: 217/255, green: 217/255, blue: 217/255, alpha: 1.0).cgColor } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/MessageViewController.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/MessageViewController.swift b/Samples/ActivityFeed/Source/MessageViewController.swift index b2a152c..a004cfe 100644 --- a/Samples/ActivityFeed/Source/MessageViewController.swift +++ b/Samples/ActivityFeed/Source/MessageViewController.swift @@ -36,7 +36,7 @@ class MessageViewController : SLKTextViewController { private var messageEntities: [ActivityEntity] = [] init() { - super.init(tableViewStyle:.Plain) + super.init(tableViewStyle:.plain) commonInit() } @@ -45,11 +45,11 @@ class MessageViewController : SLKTextViewController { commonInit() } - override static func tableViewStyleForCoder(decoder: NSCoder) -> UITableViewStyle { - return .Plain + override static func tableViewStyle(for decoder: NSCoder) -> UITableViewStyle { + return .plain } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { self.reloadMessages() if let username = Usergrid.currentUser?.name { self.navigationItem.title = "\(username)'s Feed" @@ -60,11 +60,11 @@ class MessageViewController : SLKTextViewController { func commonInit() { self.bounces = true self.shakeToClearEnabled = true - self.keyboardPanningEnabled = true + self.isKeyboardPanningEnabled = true self.shouldScrollToBottomAfterKeyboardShows = true - self.inverted = true + self.isInverted = true - self.registerClassForTextView(MessageTextView) + self.registerClass(forTextView:MessageTextView.classForCoder()) self.activateWCSession() } @@ -78,32 +78,32 @@ class MessageViewController : SLKTextViewController { override func viewDidLoad() { super.viewDidLoad() - self.rightButton.setTitle("Send", forState: .Normal) + self.rightButton.setTitle("Send", for: []) self.textInputbar.autoHideRightButton = true self.textInputbar.maxCharCount = 256 - self.textInputbar.editorTitle.textColor = UIColor.darkGrayColor() + self.textInputbar.editorTitle.textColor = UIColor.darkGray - self.tableView!.separatorStyle = .None - self.tableView!.registerClass(MessageTableViewCell.self, forCellReuseIdentifier:MessageViewController.MESSAGE_CELL_IDENTIFIER) + self.tableView!.separatorStyle = .none + self.tableView!.register(MessageTableViewCell.self, forCellReuseIdentifier:MessageViewController.MESSAGE_CELL_IDENTIFIER) } - override func didPressRightButton(sender: AnyObject!) { + override func didPressRightButton(_ sender: Any!) { self.textView.refreshFirstResponder() UsergridManager.postFeedMessage(self.textView.text) { (response) -> Void in if let messageEntity = response.entity as? ActivityEntity { - let indexPath = NSIndexPath(forRow: 0, inSection: 0) - let rowAnimation: UITableViewRowAnimation = self.inverted ? .Bottom : .Top - let scrollPosition: UITableViewScrollPosition = self.inverted ? .Bottom : .Top + let indexPath = NSIndexPath.init(row: 0, section: 0) + let rowAnimation: UITableViewRowAnimation = self.isInverted ? .bottom : .top + let scrollPosition: UITableViewScrollPosition = self.isInverted ? .bottom : .top self.tableView!.beginUpdates() - self.messageEntities.insert(messageEntity, atIndex: 0) - self.tableView!.insertRowsAtIndexPaths([indexPath], withRowAnimation: rowAnimation) + self.messageEntities.insert(messageEntity, at: 0) + self.tableView!.insertRows(at: [indexPath as IndexPath], with: rowAnimation) self.tableView!.endUpdates() - self.tableView!.scrollToRowAtIndexPath(indexPath, atScrollPosition: scrollPosition, animated: true) - self.tableView!.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) + self.tableView!.scrollToRow(at: indexPath as IndexPath, at: scrollPosition, animated: true) + self.tableView!.reloadRows(at: [indexPath as IndexPath], with: .automatic) self.sendEntitiesToWatch(self.messageEntities) } @@ -112,35 +112,37 @@ class MessageViewController : SLKTextViewController { } override func keyForTextCaching() -> String? { - return NSBundle.mainBundle().bundleIdentifier + return Bundle.main.bundleIdentifier } - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + + override func numberOfSections(in tableView: UITableView) -> Int { return 1 } - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.messageEntities.count } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { return self.messageCellForRowAtIndexPath(indexPath) } - @IBAction func unwindToChat(segue: UIStoryboardSegue) { + @IBAction func unwindToChat(_ segue: UIStoryboardSegue) { } - func populateCell(cell:MessageTableViewCell,feedEntity:ActivityEntity) { + func populateCell(_ cell:MessageTableViewCell,feedEntity:ActivityEntity) { cell.titleLabel.text = feedEntity.displayName cell.bodyLabel.text = feedEntity.content cell.thumbnailView.image = nil - if let imageURLString = feedEntity.imageURL, imageURL = NSURL(string: imageURLString) { - NSURLSession.sharedSession().dataTaskWithURL(imageURL) { (data, response, error) in - if let imageData = data, image = UIImage(data: imageData) { - dispatch_async(dispatch_get_main_queue(), { () -> Void in + if let imageURLString = feedEntity.imageURL, let imageURL = URL(string: imageURLString) { + URLSession.shared.dataTask(with: imageURL) { (data, response, error) in + if let imageData = data, let image = UIImage(data: imageData) { + DispatchQueue.main.async(execute: { () -> Void in cell.thumbnailView.image = image }) } @@ -148,8 +150,8 @@ class MessageViewController : SLKTextViewController { } } - func messageCellForRowAtIndexPath(indexPath:NSIndexPath) -> MessageTableViewCell { - let cell = self.tableView!.dequeueReusableCellWithIdentifier(MessageViewController.MESSAGE_CELL_IDENTIFIER) as! MessageTableViewCell + func messageCellForRowAtIndexPath(_ indexPath:IndexPath) -> MessageTableViewCell { + let cell = self.tableView!.dequeueReusableCell(withIdentifier: MessageViewController.MESSAGE_CELL_IDENTIFIER) as! MessageTableViewCell self.populateCell(cell, feedEntity: self.messageEntities[indexPath.row]) cell.indexPath = indexPath @@ -158,30 +160,30 @@ class MessageViewController : SLKTextViewController { return cell } - override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - let feedEntity = messageEntities[indexPath.row] + let feedEntity = messageEntities[(indexPath as NSIndexPath).row] - guard let messageText = feedEntity.content where !messageText.isEmpty + guard let messageText = feedEntity.content, !messageText.isEmpty else { return 0 } - let messageUsername : NSString = feedEntity.displayName ?? "" + let messageUsername : NSString = (feedEntity.displayName ?? "") as NSString let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.lineBreakMode = .ByWordWrapping - paragraphStyle.alignment = .Left + paragraphStyle.lineBreakMode = .byWordWrapping + paragraphStyle.alignment = .left let pointSize = MessageTableViewCell.defaultFontSize - let attributes = [NSFontAttributeName:UIFont.boldSystemFontOfSize(pointSize),NSParagraphStyleAttributeName:paragraphStyle] + let attributes = [NSFontAttributeName:UIFont.boldSystemFont(ofSize: pointSize),NSParagraphStyleAttributeName:paragraphStyle] - let width: CGFloat = CGRectGetWidth(self.tableView!.frame) - MessageTableViewCell.kMessageTableViewCellAvatarHeight - 25 + let width: CGFloat = self.tableView!.frame.width - MessageTableViewCell.kMessageTableViewCellAvatarHeight - 25 - let titleBounds = messageUsername.boundingRectWithSize(CGSize(width: width, height: CGFloat.max), options: .UsesLineFragmentOrigin, attributes: attributes, context: nil) - let bodyBounds = messageText.boundingRectWithSize(CGSize(width: width, height: CGFloat.max), options: .UsesLineFragmentOrigin, attributes: attributes, context: nil) + let titleBounds = messageUsername.boundingRect(with: CGSize(width: width, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil) + let bodyBounds = messageText.boundingRect(with: CGSize(width: width, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil) - var height = CGRectGetHeight(titleBounds) + CGRectGetHeight(bodyBounds) + 40 + var height = titleBounds.height + bodyBounds.height + 40 if height < MessageTableViewCell.kMessageTableViewCellMinimumHeight { height = MessageTableViewCell.kMessageTableViewCellMinimumHeight } @@ -194,24 +196,47 @@ extension MessageViewController : WCSessionDelegate { func activateWCSession() { if (WCSession.isSupported()) { - let session = WCSession.defaultSession() + let session = WCSession.default() session.delegate = self - session.activateSession() + session.activate() + } + } + + @available(iOS 9.3, *) + func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { + + } + + func sessionDidBecomeInactive(_ session: WCSession) { + + } + + func sessionDidDeactivate(_ session: WCSession) { + + } + + func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Swift.Void) { + if let action = message["action"] as? String, action == "getMessages" { + UsergridManager.getFeedMessages { (response) -> Void in + if let entities = response.entities { + self.sendEntitiesToWatch(entities) + } + } } } - func sendEntitiesToWatch(messages:[UsergridEntity]) { - if WCSession.defaultSession().reachable { - NSKeyedArchiver.setClassName("ActivityEntity", forClass: ActivityEntity.self) - let data = NSKeyedArchiver.archivedDataWithRootObject(messages) - WCSession.defaultSession().sendMessageData(data, replyHandler: nil, errorHandler: { (error) -> Void in - self.showAlert(title: "WCSession Unreachable.", message: "\(error)") + func sendEntitiesToWatch(_ messages:[UsergridEntity]) { + if WCSession.default().isReachable { + NSKeyedArchiver.setClassName("ActivityEntity", for: ActivityEntity.self) + let data = NSKeyedArchiver.archivedData(withRootObject: messages) + WCSession.default().sendMessageData(data, replyHandler: nil, errorHandler: { (error) -> Void in + self.showAlert("WCSession Unreachable.", message: "\(error)") }) } } - func session(session: WCSession, didReceiveMessage message: [String : AnyObject]) { - if let action = message["action"] as? String where action == "getMessages" { + func session(_ session: WCSession, didReceiveMessage message: [String : Any]) { + if let action = message["action"] as? String, action == "getMessages" { UsergridManager.getFeedMessages { (response) -> Void in if let entities = response.entities { self.sendEntitiesToWatch(entities) http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/RegisterViewController.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/RegisterViewController.swift b/Samples/ActivityFeed/Source/RegisterViewController.swift index 25cad11..f2cbae5 100644 --- a/Samples/ActivityFeed/Source/RegisterViewController.swift +++ b/Samples/ActivityFeed/Source/RegisterViewController.swift @@ -35,27 +35,27 @@ class RegisterViewController: UIViewController { @IBOutlet weak var emailTextField: UITextField! @IBOutlet weak var passwordTextField: UITextField! - @IBAction func registerButtonTouched(sender: AnyObject) { - guard let name = nameTextField.text where !name.isEmpty, - let username = usernameTextField.text where !username.isEmpty, - let email = emailTextField.text where !email.isEmpty, - let password = passwordTextField.text where !password.isEmpty + @IBAction func registerButtonTouched(_ sender: AnyObject) { + guard let name = nameTextField.text, !name.isEmpty, + let username = usernameTextField.text, !username.isEmpty, + let email = emailTextField.text, !email.isEmpty, + let password = passwordTextField.text, !password.isEmpty else { - self.showAlert(title: "Error Registering User", message: "Name, username, email, and password fields must not be empty.") + self.showAlert("Error Registering User", message: "Name, username, email, and password fields must not be empty.") return; } self.createUser(name, username: username, email: email, password: password) } - private func createUser(name:String, username:String, email:String, password:String) { + private func createUser(_ name:String, username:String, email:String, password:String) { UsergridManager.createUser(name, username: username, email: email, password: password) { (response) -> Void in if let createdUser = response.user { - self.showAlert(title: "Registering User Successful", message: "User description: \n \(createdUser.stringValue)") { (action) -> Void in - self.performSegueWithIdentifier("unwindSegue", sender: self) + self.showAlert("Registering User Successful", message: "User description: \n \(createdUser.stringValue)") { (action) -> Void in + self.performSegue(withIdentifier: "unwindSegue", sender: self) } } else { - self.showAlert(title: "Error Registering User", message: response.error?.errorDescription) + self.showAlert("Error Registering User", message: response.error?.errorDescription) } } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/UsergridManager.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/UsergridManager.swift b/Samples/ActivityFeed/Source/UsergridManager.swift index 99fe4b5..7130490 100644 --- a/Samples/ActivityFeed/Source/UsergridManager.swift +++ b/Samples/ActivityFeed/Source/UsergridManager.swift @@ -40,29 +40,29 @@ public class UsergridManager { ActivityEntity.registerSubclass() } - static func loginUser(username:String, password:String, completion:UsergridUserAuthCompletionBlock) { + static func loginUser(_ username:String, password:String, completion:UsergridUserAuthCompletionBlock) { let userAuth = UsergridUserAuth(username: username, password: password) Usergrid.authenticateUser(userAuth, completion: completion) } - static func createUser(name:String, username:String, email:String, password:String, completion:UsergridResponseCompletion) { - let user = UsergridUser(name: name, propertyDict: [UsergridUserProperties.Username.stringValue:username, - UsergridUserProperties.Email.stringValue:email, - UsergridUserProperties.Password.stringValue:password]) + static func createUser(_ name:String, username:String, email:String, password:String, completion:UsergridResponseCompletion) { + let user = UsergridUser(name: name, propertyDict: [UsergridUserProperties.username.stringValue:username, + UsergridUserProperties.email.stringValue:email, + UsergridUserProperties.password.stringValue:password]) user.create(completion) } - static func getFeedMessages(completion:UsergridResponseCompletion) { - Usergrid.GET(UsergridQuery("users/me/feed").desc(UsergridEntityProperties.Created.stringValue), queryCompletion: completion) + static func getFeedMessages(_ completion:UsergridResponseCompletion) { + Usergrid.GET(UsergridQuery("users/me/feed").desc(UsergridEntityProperties.created.stringValue), queryCompletion: completion) } - static func postFeedMessage(text:String,completion:UsergridResponseCompletion) { + static func postFeedMessage(_ text:String,completion:UsergridResponseCompletion) { let currentUser = Usergrid.currentUser! let verb = "post" let content = text - var actorDictionary = [String:AnyObject]() + var actorDictionary = [String:Any]() actorDictionary["displayName"] = currentUser.name ?? currentUser.usernameOrEmail ?? "" actorDictionary["email"] = currentUser.email ?? "" if let imageURL = currentUser.picture { @@ -72,7 +72,7 @@ public class UsergridManager { Usergrid.POST("users/me/activities", jsonBody: ["actor":actorDictionary,"verb":verb,"content":content], completion: completion) } - static func followUser(username:String, completion:UsergridResponseCompletion) { + static func followUser(_ username:String, completion:UsergridResponseCompletion) { Usergrid.connect("users", entityID: "me", relationship: "following", toType: "users", toName: username, completion: completion) } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/Source/ViewControllerExtensions.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/Source/ViewControllerExtensions.swift b/Samples/ActivityFeed/Source/ViewControllerExtensions.swift index ad79741..c81f177 100644 --- a/Samples/ActivityFeed/Source/ViewControllerExtensions.swift +++ b/Samples/ActivityFeed/Source/ViewControllerExtensions.swift @@ -27,10 +27,10 @@ import UIKit extension UIViewController { - func showAlert(title title: String, message: String?, handler:((UIAlertAction) -> Void)? = nil) { - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) - alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: handler)) - self.presentViewController(alert, animated: true, completion: nil) + func showAlert(_ title: String, message: String?, handler:((UIAlertAction) -> Void)? = nil) { + let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.default, handler: handler)) + self.present(alert, animated: true, completion: nil) } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/ActivityFeed/WatchSample Extension/InterfaceController.swift ---------------------------------------------------------------------- diff --git a/Samples/ActivityFeed/WatchSample Extension/InterfaceController.swift b/Samples/ActivityFeed/WatchSample Extension/InterfaceController.swift index a61192a..18a0adf 100644 --- a/Samples/ActivityFeed/WatchSample Extension/InterfaceController.swift +++ b/Samples/ActivityFeed/WatchSample Extension/InterfaceController.swift @@ -34,19 +34,23 @@ class InterfaceController: WKInterfaceController,WCSessionDelegate { @IBOutlet var messageTable: WKInterfaceTable! var messageEntities: [ActivityEntity] = [] - override func awakeWithContext(context: AnyObject?) { - super.awakeWithContext(context) + override func awake(withContext context: Any?) { + super.awake(withContext: context) if WCSession.isSupported() { - let session = WCSession.defaultSession() + let session = WCSession.default() session.delegate = self - session.activateSession() + session.activate() } } + func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { + + } + override func willActivate() { self.reloadTable() - if WCSession.defaultSession().reachable { - WCSession.defaultSession().sendMessage(["action":"getMessages"], replyHandler: nil) { (error) -> Void in + if WCSession.default().isReachable { + WCSession.default().sendMessage(["action":"getMessages"], replyHandler: nil) { (error) -> Void in print(error) } } @@ -56,7 +60,7 @@ class InterfaceController: WKInterfaceController,WCSessionDelegate { func reloadTable() { self.messageTable.setNumberOfRows(messageEntities.count, withRowType: "MessageRow") for index in 0..<self.messageTable.numberOfRows { - if let controller = self.messageTable.rowControllerAtIndex(index) as? MessageRowController { + if let controller = self.messageTable.rowController(at: index) as? MessageRowController { let messageEntity = messageEntities[index] controller.titleLabel.setText(messageEntity.displayName) controller.messageLabel.setText(messageEntity.content) @@ -64,9 +68,9 @@ class InterfaceController: WKInterfaceController,WCSessionDelegate { } } - func session(session: WCSession, didReceiveMessageData messageData: NSData) { + func session(_ session: WCSession, didReceiveMessageData messageData: Data) { NSKeyedUnarchiver.setClass(ActivityEntity.self, forClassName: "ActivityEntity") - if let messageEntities = NSKeyedUnarchiver.unarchiveObjectWithData(messageData) as? [ActivityEntity] { + if let messageEntities = NSKeyedUnarchiver.unarchiveObject(with: messageData) as? [ActivityEntity] { self.messageEntities = messageEntities self.reloadTable() } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/Push/Push.xcodeproj/project.pbxproj ---------------------------------------------------------------------- diff --git a/Samples/Push/Push.xcodeproj/project.pbxproj b/Samples/Push/Push.xcodeproj/project.pbxproj index f786e4e..414f073 100644 --- a/Samples/Push/Push.xcodeproj/project.pbxproj +++ b/Samples/Push/Push.xcodeproj/project.pbxproj @@ -201,6 +201,7 @@ TargetAttributes = { 637A71EF1C5BF7B10056545A = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; }; }; }; @@ -428,6 +429,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.usergridpushsample; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -443,6 +445,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.usergridpushsample; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SWIFT_VERSION = 3.0; }; name = Release; }; http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/Push/Source/AppDelegate.swift ---------------------------------------------------------------------- diff --git a/Samples/Push/Source/AppDelegate.swift b/Samples/Push/Source/AppDelegate.swift index 0ce64dd..e13348b 100644 --- a/Samples/Push/Source/AppDelegate.swift +++ b/Samples/Push/Source/AppDelegate.swift @@ -32,21 +32,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { UsergridManager.initializeSharedInstance() - application.registerUserNotificationSettings(UIUserNotificationSettings( forTypes: [.Alert, .Badge, .Sound], categories: nil)) + application.registerUserNotificationSettings(UIUserNotificationSettings( types: [.alert, .badge, .sound], categories: nil)) application.registerForRemoteNotifications() return true } - func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { + func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { UsergridManager.applyPushToken(deviceToken) } - func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { + func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { print("Application failed to register for remote notifications") } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/Push/Source/UsergridManager.swift ---------------------------------------------------------------------- diff --git a/Samples/Push/Source/UsergridManager.swift b/Samples/Push/Source/UsergridManager.swift index 00e8ec2..bcdcb98 100644 --- a/Samples/Push/Source/UsergridManager.swift +++ b/Samples/Push/Source/UsergridManager.swift @@ -39,7 +39,7 @@ public class UsergridManager { Usergrid.initSharedInstance(configuration: UsergridClientConfig(orgId: UsergridManager.ORG_ID, appId: UsergridManager.APP_ID, baseUrl: UsergridManager.BASE_URL)) } - static func applyPushToken(deviceToken:NSData) { + static func applyPushToken(_ deviceToken:Data) { Usergrid.applyPushToken(deviceToken, notifierID: UsergridManager.NOTIFIER_ID, completion: { (response) -> Void in print("Apply token completed successfully : \(response.ok)") if !response.ok, let errorDescription = response.error?.errorDescription { @@ -48,8 +48,8 @@ public class UsergridManager { }) } - static func sendPush(deviceId deviceId:String,message:String) { - let pushRequest = UsergridRequest(method: .Post, + static func sendPush(deviceId:String,message:String) { + let pushRequest = UsergridRequest(method: .post, baseUrl: Usergrid.clientAppURL, paths: ["devices",deviceId,"notifications"], auth: Usergrid.authForRequests(), @@ -69,4 +69,4 @@ public class UsergridManager { static func pushToAllDevices() { UsergridManager.sendPush(deviceId: "*", message: "Push to all devices message.") } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Samples/Push/Source/ViewController.swift ---------------------------------------------------------------------- diff --git a/Samples/Push/Source/ViewController.swift b/Samples/Push/Source/ViewController.swift index d1e3247..ec130d3 100644 --- a/Samples/Push/Source/ViewController.swift +++ b/Samples/Push/Source/ViewController.swift @@ -28,11 +28,11 @@ import UIKit class ViewController: UIViewController { - @IBAction func pushToThisDevice(sender: AnyObject) { + @IBAction func pushToThisDevice(_ sender: AnyObject) { UsergridManager.pushToThisDevice() } - @IBAction func pushToAllDevices(sender: AnyObject) { + @IBAction func pushToAllDevices(_ sender: AnyObject) { UsergridManager.pushToAllDevices() } } http://git-wip-us.apache.org/repos/asf/usergrid-swift/blob/b022377f/Source/Usergrid.swift ---------------------------------------------------------------------- diff --git a/Source/Usergrid.swift b/Source/Usergrid.swift index ac87380..f9807f3 100644 --- a/Source/Usergrid.swift +++ b/Source/Usergrid.swift @@ -103,7 +103,8 @@ public class Usergrid: NSObject { - returns: The shared instance of `UsergridClient`. */ - public static func initSharedInstance(orgId orgId : String, appId: String) -> UsergridClient { + @discardableResult + public static func initSharedInstance(orgId : String, appId: String) -> UsergridClient { if !Usergrid.isInitialized { Usergrid._sharedClient = UsergridClient(orgId: orgId, appId: appId) } else { @@ -121,7 +122,8 @@ public class Usergrid: NSObject { - returns: The shared instance of `UsergridClient`. */ - public static func initSharedInstance(orgId orgId : String, appId: String, baseUrl: String) -> UsergridClient { + @discardableResult + public static func initSharedInstance(orgId : String, appId: String, baseUrl: String) -> UsergridClient { if !Usergrid.isInitialized { Usergrid._sharedClient = UsergridClient(orgId: orgId, appId: appId, baseUrl: baseUrl) } else { @@ -137,7 +139,8 @@ public class Usergrid: NSObject { - returns: The shared instance of `UsergridClient`. */ - public static func initSharedInstance(configuration configuration: UsergridClientConfig) -> UsergridClient { + @discardableResult + public static func initSharedInstance(configuration: UsergridClientConfig) -> UsergridClient { if !Usergrid.isInitialized { Usergrid._sharedClient = UsergridClient(configuration: configuration) } else { @@ -155,7 +158,7 @@ public class Usergrid: NSObject { - parameter notifierID: The Usergrid notifier ID. - parameter completion: The completion block. */ - public static func applyPushToken(pushToken: NSData, notifierID: String, completion: UsergridResponseCompletion? = nil) { + public static func applyPushToken(_ pushToken: Data, notifierID: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.applyPushToken(pushToken, notifierID: notifierID, completion: completion) } @@ -167,7 +170,7 @@ public class Usergrid: NSObject { - parameter notifierID: The Usergrid notifier ID. - parameter completion: The completion block. */ - public static func applyPushToken(device: UsergridDevice, pushToken: NSData, notifierID: String, completion: UsergridResponseCompletion? = nil) { + public static func applyPushToken(_ device: UsergridDevice, pushToken: Data, notifierID: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.applyPushToken(device, pushToken: pushToken, notifierID: notifierID, completion: completion) } @@ -183,7 +186,7 @@ public class Usergrid: NSObject { - returns: The shared instance of `UsergridClient` */ - public static func usingAuth(auth:UsergridAuth) -> UsergridClient { + public static func usingAuth(_ auth:UsergridAuth) -> UsergridClient { return Usergrid.sharedInstance.usingAuth(auth) } @@ -196,7 +199,7 @@ public class Usergrid: NSObject { - returns: The shared instance of `UsergridClient` */ - public static func usingToken(token:String) -> UsergridClient { + public static func usingToken(_ token:String) -> UsergridClient { return Usergrid.sharedInstance.usingToken(token) } @@ -219,7 +222,7 @@ public class Usergrid: NSObject { - parameter completion: The completion block that will be called after authentication has completed. */ - public static func authenticateApp(completion: UsergridAppAuthCompletionBlock? = nil) { + public static func authenticateApp(_ completion: UsergridAppAuthCompletionBlock? = nil) { Usergrid.sharedInstance.authenticateApp(completion) } @@ -229,7 +232,7 @@ public class Usergrid: NSObject { - parameter auth: The `UsergridAppAuth` that will be authenticated. - parameter completion: The completion block that will be called after authentication has completed. */ - public static func authenticateApp(auth: UsergridAppAuth, completion: UsergridAppAuthCompletionBlock? = nil) { + public static func authenticateApp(_ auth: UsergridAppAuth, completion: UsergridAppAuthCompletionBlock? = nil) { Usergrid.sharedInstance.authenticateApp(auth, completion: completion) } @@ -239,7 +242,7 @@ public class Usergrid: NSObject { - parameter auth: The `UsergridUserAuth` that will be authenticated. - parameter completion: The completion block that will be called after authentication has completed. */ - public static func authenticateUser(auth: UsergridUserAuth, completion: UsergridUserAuthCompletionBlock? = nil) { + public static func authenticateUser(_ auth: UsergridUserAuth, completion: UsergridUserAuthCompletionBlock? = nil) { Usergrid.sharedInstance.authenticateUser(auth, completion: completion) } @@ -250,7 +253,7 @@ public class Usergrid: NSObject { - parameter setAsCurrentUser: If the authenticated user should be set as the `UsergridClient.currentUser`. - parameter completion: The completion block that will be called after authentication has completed. */ - public static func authenticateUser(userAuth: UsergridUserAuth, setAsCurrentUser:Bool, completion: UsergridUserAuthCompletionBlock? = nil) { + public static func authenticateUser(_ userAuth: UsergridUserAuth, setAsCurrentUser:Bool, completion: UsergridUserAuthCompletionBlock? = nil) { Usergrid.sharedInstance.authenticateUser(userAuth, setAsCurrentUser: setAsCurrentUser, completion: completion) } @@ -262,7 +265,7 @@ public class Usergrid: NSObject { - parameter new: The new password. - parameter completion: The optional completion block. */ - public static func resetPassword(user: UsergridUser, old:String, new:String, completion:UsergridUserResetPasswordCompletion? = nil) { + public static func resetPassword(_ user: UsergridUser, old:String, new:String, completion:UsergridUserResetPasswordCompletion? = nil) { Usergrid.sharedInstance.resetPassword(user, old: old, new: new, completion: completion) } @@ -271,7 +274,7 @@ public class Usergrid: NSObject { - parameter completion: The completion block that will be called after logout has completed. */ - public static func logoutCurrentUser(completion:UsergridResponseCompletion? = nil) { + public static func logoutCurrentUser(_ completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.logoutCurrentUser(completion) } @@ -280,7 +283,7 @@ public class Usergrid: NSObject { - parameter completion: The completion block that will be called after logout has completed. */ - public static func logoutUserAllTokens(uuidOrUsername:String, completion:UsergridResponseCompletion? = nil) { + public static func logoutUserAllTokens(_ uuidOrUsername:String, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.logoutUserAllTokens(uuidOrUsername, completion: completion) } @@ -291,7 +294,7 @@ public class Usergrid: NSObject { - parameter completion: The completion block that will be called after logout has completed. */ - public static func logoutUser(uuidOrUsername:String, token:String?, completion:UsergridResponseCompletion? = nil) { + public static func logoutUser(_ uuidOrUsername:String, token:String?, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.logoutUser(uuidOrUsername, token: token, completion: completion) } @@ -305,7 +308,7 @@ public class Usergrid: NSObject { - parameter request: The `UsergridRequest` object to send. - parameter completion: The optional completion block that will be called once the request has completed. */ - public static func sendRequest(request:UsergridRequest, completion:UsergridResponseCompletion? = nil) { + public static func sendRequest(_ request:UsergridRequest, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.sendRequest(request, completion: completion) } @@ -318,7 +321,7 @@ public class Usergrid: NSObject { - parameter uuidOrName: The UUID or name of the `UsergridEntity`. - parameter completion: The completion block that will be called once the request has completed. */ - public static func GET(type: String, uuidOrName: String, completion: UsergridResponseCompletion? = nil) { + public static func GET(_ type: String, uuidOrName: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.GET(type,uuidOrName:uuidOrName,completion:completion) } @@ -328,7 +331,7 @@ public class Usergrid: NSObject { - parameter type: The `UsergridEntity` type. - parameter completion: The optional completion block that will be called once the request has completed. */ - public static func GET(type: String, completion: UsergridResponseCompletion? = nil) { + public static func GET(_ type: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.GET(type,completion:completion) } @@ -338,7 +341,7 @@ public class Usergrid: NSObject { - parameter query: The query to use when gathering `UsergridEntity` objects. - parameter queryCompletion: The completion block that will be called once the request has completed. */ - public static func GET(query: UsergridQuery, queryCompletion: UsergridResponseCompletion? = nil) { + public static func GET(_ query: UsergridQuery, queryCompletion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.GET(query,queryCompletion:queryCompletion) } @@ -352,7 +355,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionary to update the `UsergridEntity` with. - parameter completion: The completion block that will be called once the request has completed. */ - public static func PUT(type: String, uuidOrName: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion? = nil) { + public static func PUT(_ type: String, uuidOrName: String, jsonBody:[String:Any], completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.PUT(type, uuidOrName: uuidOrName, jsonBody: jsonBody, completion: completion) } @@ -365,7 +368,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionary to update the `UsergridEntity` with. - parameter completion: The completion block that will be called once the request has completed. */ - public static func PUT(type: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion? = nil) { + public static func PUT(_ type: String, jsonBody:[String:Any], completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.PUT(type, jsonBody: jsonBody, completion: completion) } @@ -375,7 +378,7 @@ public class Usergrid: NSObject { - parameter entity: The `UsergridEntity` to update. - parameter completion: The completion block that will be called once the request has completed. */ - public static func PUT(entity: UsergridEntity, completion: UsergridResponseCompletion? = nil) { + public static func PUT(_ entity: UsergridEntity, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.PUT(entity, completion: completion) } @@ -388,7 +391,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionary to update with. - parameter queryCompletion: The completion block that will be called once the request has completed. */ - public static func PUT(query: UsergridQuery, jsonBody:[String:AnyObject], queryCompletion: UsergridResponseCompletion? = nil) { + public static func PUT(_ query: UsergridQuery, jsonBody:[String:Any], queryCompletion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.PUT(query, jsonBody: jsonBody, queryCompletion: queryCompletion) } @@ -402,7 +405,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionary to use when creating the `UsergridEntity`. - parameter completion: The completion block that will be called once the request has completed. */ - public static func POST(type: String, name: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion? = nil) { + public static func POST(_ type: String, name: String, jsonBody:[String:Any], completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.POST(type, name: name, jsonBody: jsonBody, completion: completion) } @@ -413,7 +416,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionary to use when creating the `UsergridEntity`. - parameter completion: The completion block that will be called once the request has completed. */ - public static func POST(type: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion? = nil) { + public static func POST(_ type: String, jsonBody:[String:Any], completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.POST(type, jsonBody: jsonBody, completion: completion) } @@ -424,7 +427,7 @@ public class Usergrid: NSObject { - parameter jsonBody: The valid JSON body dictionaries to use when creating the `UsergridEntity` objects. - parameter completion: The completion block that will be called once the request has completed. */ - public static func POST(type: String, jsonBodies:[[String:AnyObject]], completion: UsergridResponseCompletion? = nil) { + public static func POST(_ type: String, jsonBodies:[[String:Any]], completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.POST(type, jsonBodies: jsonBodies, completion: completion) } @@ -434,7 +437,7 @@ public class Usergrid: NSObject { - parameter entity: The `UsergridEntity` to create. - parameter completion: The completion block that will be called once the request has completed. */ - public static func POST(entity:UsergridEntity, completion: UsergridResponseCompletion? = nil) { + public static func POST(_ entity:UsergridEntity, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.POST(entity, completion: completion) } @@ -446,7 +449,7 @@ public class Usergrid: NSObject { - parameter entities: The `UsergridEntity` objects to create. - parameter entitiesCompletion: The completion block that will be called once the request has completed. */ - public static func POST(entities:[UsergridEntity], entitiesCompletion: UsergridResponseCompletion? = nil) { + public static func POST(_ entities:[UsergridEntity], entitiesCompletion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.POST(entities, entitiesCompletion: entitiesCompletion) } @@ -459,7 +462,7 @@ public class Usergrid: NSObject { - parameter uuidOrName: The UUID or name of the `UsergridEntity`. - parameter completion: The completion block that will be called once the request has completed. */ - public static func DELETE(type:String, uuidOrName: String, completion: UsergridResponseCompletion? = nil) { + public static func DELETE(_ type:String, uuidOrName: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.DELETE(type, uuidOrName: uuidOrName, completion: completion) } @@ -471,7 +474,7 @@ public class Usergrid: NSObject { - parameter entity: The `UsergridEntity` to delete. - parameter completion: The completion block that will be called once the request has completed. */ - public static func DELETE(entity:UsergridEntity, completion: UsergridResponseCompletion? = nil) { + public static func DELETE(_ entity:UsergridEntity, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.DELETE(entity, completion:completion) } @@ -483,7 +486,7 @@ public class Usergrid: NSObject { - parameter query: The query to use when filtering what entities to delete. - parameter queryCompletion: The completion block that will be called once the request has completed. */ - public static func DELETE(query:UsergridQuery, queryCompletion: UsergridResponseCompletion? = nil) { + public static func DELETE(_ query:UsergridQuery, queryCompletion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.DELETE(query, queryCompletion:queryCompletion) } @@ -497,7 +500,7 @@ public class Usergrid: NSObject { - parameter to: The entity which is connected. - parameter completion: The completion block that will be called once the request has completed. */ - public static func connect(entity:UsergridEntity, relationship:String, to:UsergridEntity, completion: UsergridResponseCompletion? = nil) { + public static func connect(_ entity:UsergridEntity, relationship:String, to:UsergridEntity, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.connect(entity, relationship: relationship, to: to, completion: completion) } @@ -511,7 +514,7 @@ public class Usergrid: NSObject { - parameter toID: The UUID of the entity you are connecting to. - parameter completion: The completion block that will be called once the request has completed. */ - public static func connect(entityType:String, entityID:String, relationship:String, toType:String?, toID: String, completion: UsergridResponseCompletion? = nil) { + public static func connect(_ entityType:String, entityID:String, relationship:String, toType:String?, toID: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.connect(entityType, entityID: entityID, relationship: relationship, toType: toType, toID: toID, completion: completion) } @@ -525,7 +528,7 @@ public class Usergrid: NSObject { - parameter toName: The name of the entity you are connecting to. - parameter completion: The completion block that will be called once the request has completed. */ - public static func connect(entityType:String, entityID:String, relationship:String, toType:String, toName: String, completion: UsergridResponseCompletion? = nil) { + public static func connect(_ entityType:String, entityID:String, relationship:String, toType:String, toName: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.connect(entityType, entityID: entityID, relationship: relationship, toType: toType, toName: toName, completion: completion) } @@ -538,7 +541,7 @@ public class Usergrid: NSObject { - parameter connectingEntity: The entity which is connected. - parameter completion: The completion block that will be called once the request has completed. */ - public static func disconnect(entity:UsergridEntity, relationship:String, from:UsergridEntity, completion: UsergridResponseCompletion? = nil) { + public static func disconnect(_ entity:UsergridEntity, relationship:String, from:UsergridEntity, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.disconnect(entity, relationship: relationship, from: from, completion: completion) } @@ -552,7 +555,7 @@ public class Usergrid: NSObject { - parameter toID: The UUID of the entity you are disconnecting from. - parameter completion: The completion block that will be called once the request has completed. */ - public static func disconnect(entityType:String, entityID:String, relationship:String, fromType:String?, fromID: String, completion: UsergridResponseCompletion? = nil) { + public static func disconnect(_ entityType:String, entityID:String, relationship:String, fromType:String?, fromID: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.disconnect(entityType, entityID: entityID, relationship: relationship, fromType: fromType, fromID: fromID, completion: completion) } @@ -566,7 +569,7 @@ public class Usergrid: NSObject { - parameter fromName: The name of the entity you are disconnecting from. - parameter completion: The completion block that will be called once the request has completed. */ - public static func disconnect(entityType:String, entityID:String, relationship:String, fromType:String, fromName: String, completion: UsergridResponseCompletion? = nil) { + public static func disconnect(_ entityType:String, entityID:String, relationship:String, fromType:String, fromName: String, completion: UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.disconnect(entityType, entityID: entityID, relationship: relationship, fromType: fromType, fromName: fromName, completion: completion) } @@ -578,7 +581,7 @@ public class Usergrid: NSObject { - parameter relationship: The relationship. - parameter completion: The completion block that will be called once the request has completed. */ - public static func getConnections(direction:UsergridDirection, entity:UsergridEntity, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { + public static func getConnections(_ direction:UsergridDirection, entity:UsergridEntity, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.getConnections(direction, entity: entity, relationship: relationship, query:query, completion: completion) } @@ -592,7 +595,7 @@ public class Usergrid: NSObject { - parameter query: The optional query. - parameter completion: The completion block that will be called once the request has completed. */ - public static func getConnections(direction:UsergridDirection, type:String, uuidOrName:String, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { + public static func getConnections(_ direction:UsergridDirection, type:String, uuidOrName:String, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.getConnections(direction, type: type, uuidOrName: uuidOrName, relationship: relationship, query:query, completion: completion) } @@ -605,7 +608,7 @@ public class Usergrid: NSObject { - parameter query: The optional query. - parameter completion: The optional completion block that will be called once the request has completed. */ - public static func getConnections(direction:UsergridDirection, uuid:String, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { + public static func getConnections(_ direction:UsergridDirection, uuid:String, relationship:String, query:UsergridQuery? = nil, completion:UsergridResponseCompletion? = nil) { Usergrid.sharedInstance.getConnections(direction, uuid: uuid, relationship: relationship, query: query, completion: completion) } @@ -619,7 +622,7 @@ public class Usergrid: NSObject { - parameter progress: The progress block that will be called to update the progress of the upload. - parameter completion: The completion block that will be called once the request has completed. */ - public static func uploadAsset(entity:UsergridEntity, asset:UsergridAsset, progress:UsergridAssetRequestProgress? = nil, completion:UsergridAssetUploadCompletion? = nil) { + public static func uploadAsset(_ entity:UsergridEntity, asset:UsergridAsset, progress:UsergridAssetRequestProgress? = nil, completion:UsergridAssetUploadCompletion? = nil) { Usergrid.sharedInstance.uploadAsset(entity, asset: asset, progress: progress, completion: completion) } @@ -631,7 +634,7 @@ public class Usergrid: NSObject { - parameter progress: The progress block that will be called to update the progress of the download. - parameter completion: The completion block that will be called once the request has completed. */ - public static func downloadAsset(entity:UsergridEntity, contentType:String, progress:UsergridAssetRequestProgress? = nil, completion:UsergridAssetDownloadCompletion? = nil) { + public static func downloadAsset(_ entity:UsergridEntity, contentType:String, progress:UsergridAssetRequestProgress? = nil, completion:UsergridAssetDownloadCompletion? = nil) { Usergrid.sharedInstance.downloadAsset(entity, contentType: contentType, progress: progress, completion: completion) } }
