Browse Source

Conversion to Swift 5

marinofaggiana 6 years ago
parent
commit
5b29aab18d

+ 9 - 9
Nextcloud.xcodeproj/project.pbxproj

@@ -3045,7 +3045,7 @@
 				TargetAttributes = {
 					F71459B41D12E3B700CAFEEC = {
 						DevelopmentTeam = 6JLRKY9ZV7;
-						LastSwiftMigration = 1000;
+						LastSwiftMigration = 1020;
 						SystemCapabilities = {
 							com.apple.ApplicationGroups.iOS = {
 								enabled = 1;
@@ -3058,12 +3058,12 @@
 					F771E3CF20E2392D00AFB62D = {
 						CreatedOnToolsVersion = 9.4.1;
 						DevelopmentTeam = 6JLRKY9ZV7;
-						LastSwiftMigration = 1000;
+						LastSwiftMigration = 1020;
 						ProvisioningStyle = Automatic;
 					};
 					F77B0DEB1D118A16002130FE = {
 						DevelopmentTeam = 6JLRKY9ZV7;
-						LastSwiftMigration = 1000;
+						LastSwiftMigration = 1020;
 						ProvisioningStyle = Automatic;
 						SystemCapabilities = {
 							com.apple.Push = {
@@ -3893,7 +3893,7 @@
 				SKIP_INSTALL = YES;
 				SWIFT_OBJC_BRIDGING_HEADER = "Share/Share-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USE_HEADERMAP = YES;
 			};
@@ -3934,7 +3934,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 				SWIFT_OBJC_BRIDGING_HEADER = "Share/Share-Bridging-Header.h";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USE_HEADERMAP = YES;
 			};
@@ -3984,7 +3984,7 @@
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
 				SWIFT_OBJC_BRIDGING_HEADER = "File Provider Extension/FileProviderExtension-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Debug;
@@ -4030,7 +4030,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 				SWIFT_OBJC_BRIDGING_HEADER = "File Provider Extension/FileProviderExtension-Bridging-Header.h";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Release;
@@ -4073,7 +4073,7 @@
 				PROVISIONING_PROFILE_SPECIFIER = "";
 				SWIFT_OBJC_BRIDGING_HEADER = "iOSClient/Nextcloud-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USE_HEADERMAP = YES;
 				VERSIONING_SYSTEM = "";
@@ -4117,7 +4117,7 @@
 				PROVISIONING_PROFILE = "";
 				PROVISIONING_PROFILE_SPECIFIER = "";
 				SWIFT_OBJC_BRIDGING_HEADER = "iOSClient/Nextcloud-Bridging-Header.h";
-				SWIFT_VERSION = 4.2;
+				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USE_HEADERMAP = YES;
 				VERSIONING_SYSTEM = "";

+ 1 - 1
iOSClient/Database/NCManageDatabase.swift

@@ -2231,7 +2231,7 @@ class NCManageDatabase: NSObject {
             if (result.shareUserAndGroup.contains(share)) {
                     
                 var shares : [String] = result.shareUserAndGroup.components(separatedBy: ",")
-                if let index = shares.index(of:share) {
+                if let index = shares.firstIndex(of:share) {
                     shares.remove(at: index)
                 }
                 result.shareUserAndGroup = shares.joined(separator: ",")

+ 2 - 2
iOSClient/Main/NCMainCommon.swift

@@ -1093,7 +1093,7 @@ class CCMainTabBarController : UITabBarController, UITabBarControllerDelegate {
     func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
             
         let tabViewControllers = tabBarController.viewControllers!
-        guard let toIndex = tabViewControllers.index(of: viewController) else {
+        guard let toIndex = tabViewControllers.firstIndex(of: viewController) else {
                 
             if let vc = viewController as? UINavigationController {
                 vc.popToRootViewController(animated: true);
@@ -1112,7 +1112,7 @@ class CCMainTabBarController : UITabBarController, UITabBarControllerDelegate {
         let tabViewControllers = viewControllers!
         let fromView = selectedViewController!.view!
         let toView = tabViewControllers[toIndex].view!
-        let fromIndex = tabViewControllers.index(of: selectedViewController!)
+        let fromIndex = tabViewControllers.firstIndex(of: selectedViewController!)
             
         guard fromIndex != toIndex else {return}
             

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -396,7 +396,7 @@ extension NCMedia: UICollectionViewDelegate {
         metadataPush = metadata
         
         if isEditMode {
-            if let index = selectFileID.index(of: metadata.fileID) {
+            if let index = selectFileID.firstIndex(of: metadata.fileID) {
                 selectFileID.remove(at: index)
             } else {
                 selectFileID.append(metadata.fileID)

+ 2 - 2
iOSClient/Notification/CCNotification.swift

@@ -90,7 +90,7 @@ class CCNotification: UITableViewController {
                         
                         let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
                         
-                        if let index = listOfNotifications.index(where: {$0.idNotification == notification.idNotification})  {
+                        if let index = listOfNotifications.firstIndex(where: {$0.idNotification == notification.idNotification})  {
                             self.appDelegate.listOfNotifications.removeObject(at: index)
                         }
                         
@@ -133,7 +133,7 @@ class CCNotification: UITableViewController {
                                     
                                     let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
                                     
-                                    if let index = listOfNotifications.index(where: {$0.idNotification == notification.idNotification})  {
+                                    if let index = listOfNotifications.firstIndex(where: {$0.idNotification == notification.idNotification})  {
                                         self.appDelegate.listOfNotifications.removeObject(at: index)
                                     }
                                     

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -546,7 +546,7 @@ extension NCOffline: UICollectionViewDelegate {
         metadataPush = metadata
         
         if isEditMode {
-            if let index = selectFileID.index(of: metadata.fileID) {
+            if let index = selectFileID.firstIndex(of: metadata.fileID) {
                 selectFileID.remove(at: index)
             } else {
                 selectFileID.append(metadata.fileID)

+ 1 - 1
iOSClient/Select/NCSelect.swift

@@ -526,7 +526,7 @@ extension NCSelect: UICollectionViewDelegate {
         }
         
         if isEditMode {
-            if let index = selectFileID.index(of: metadata.fileID) {
+            if let index = selectFileID.firstIndex(of: metadata.fileID) {
                 selectFileID.remove(at: index)
             } else {
                 selectFileID.append(metadata.fileID)

+ 1 - 1
iOSClient/Trash/NCTrash.swift

@@ -473,7 +473,7 @@ extension NCTrash: UICollectionViewDelegate {
         let tableTrash = datasource[indexPath.item]
         
         if isEditMode {
-            if let index = selectFileID.index(of: tableTrash.fileID) {
+            if let index = selectFileID.firstIndex(of: tableTrash.fileID) {
                 selectFileID.remove(at: index)
             } else {
                 selectFileID.append(tableTrash.fileID)