From 5f6099e322612afe4356a83040506b35f17e50ec Mon Sep 17 00:00:00 2001 From: Rico237 Date: Sun, 23 Jun 2019 14:20:51 +0200 Subject: [PATCH 1/7] Update for Swift 5.0 version --- .swift-version | 2 +- SwiftMultiSelect/CustomTableCell.swift | 2 +- .../MultiSelectionCollectionView.swift | 2 +- .../MultiSelectionTableView.swift | 12 ++--- .../MultiSelectionViewController.swift | 6 +-- .../Pods/Pods.xcodeproj/project.pbxproj | 48 +++++++++++++------ .../xcschemes/xcschememanagement.plist | 19 ++++++++ .../project.pbxproj | 35 ++++++++++---- .../xcschemes/xcschememanagement.plist | 14 ++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../SwiftMultiSelectExample/AppDelegate.swift | 2 +- .../AppIcon.appiconset/Contents.json | 5 ++ 12 files changed, 119 insertions(+), 36 deletions(-) create mode 100644 SwiftMultiSelectExample/Pods/Pods.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 SwiftMultiSelectExample/SwiftMultiSelectExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.swift-version b/.swift-version index 9f55b2c..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +5.0 diff --git a/SwiftMultiSelect/CustomTableCell.swift b/SwiftMultiSelect/CustomTableCell.swift index e5c2f76..768b2d4 100644 --- a/SwiftMultiSelect/CustomTableCell.swift +++ b/SwiftMultiSelect/CustomTableCell.swift @@ -86,7 +86,7 @@ class CustomTableCell: UITableViewCell /// - Parameters: /// - style: style for cell /// - reuseIdentifier: string for reuse - override init(style: UITableViewCellStyle, reuseIdentifier: String!) + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String!) { //First Call Super super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/SwiftMultiSelect/MultiSelectionCollectionView.swift b/SwiftMultiSelect/MultiSelectionCollectionView.swift index ab3e09b..f1ad20e 100644 --- a/SwiftMultiSelect/MultiSelectionCollectionView.swift +++ b/SwiftMultiSelect/MultiSelectionCollectionView.swift @@ -137,7 +137,7 @@ extension MultiSelecetionViewController:UICollectionViewDelegate,UICollectionVie if remove { //For remove from collection view and create IndexPath, i need the index posistion in the array - let id = selectedItems.index { (itm) -> Bool in + let id = selectedItems.firstIndex { (itm) -> Bool in itm.row == idp } diff --git a/SwiftMultiSelect/MultiSelectionTableView.swift b/SwiftMultiSelect/MultiSelectionTableView.swift index 1247f72..f634938 100644 --- a/SwiftMultiSelect/MultiSelectionTableView.swift +++ b/SwiftMultiSelect/MultiSelectionTableView.swift @@ -109,13 +109,13 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc //Set initial state - if let itm_pre = self.selectedItems.index(where: { (itm) -> Bool in + if let itm_pre = self.selectedItems.firstIndex(where: { (itm) -> Bool in itm == item }){ self.selectedItems[itm_pre].color = cell.initials.backgroundColor! - cell.accessoryType = UITableViewCellAccessoryType.checkmark + cell.accessoryType = UITableViewCell.AccessoryType.checkmark }else{ - cell.accessoryType = UITableViewCellAccessoryType.none + cell.accessoryType = UITableViewCell.AccessoryType.none } @@ -169,11 +169,11 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc item.color = cell.initials.backgroundColor! //Check if cell is already selected or not - if cell.accessoryType == UITableViewCellAccessoryType.checkmark + if cell.accessoryType == UITableViewCell.AccessoryType.checkmark { //Set accessory type - cell.accessoryType = UITableViewCellAccessoryType.none + cell.accessoryType = UITableViewCell.AccessoryType.none //Comunicate deselection to delegate SwiftMultiSelect.delegate?.swiftMultiSelect(didUnselectItem: item) @@ -185,7 +185,7 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc else{ //Set accessory type - cell.accessoryType = UITableViewCellAccessoryType.checkmark + cell.accessoryType = UITableViewCell.AccessoryType.checkmark //Add current item to selected selectedItems.append(item) diff --git a/SwiftMultiSelect/MultiSelectionViewController.swift b/SwiftMultiSelect/MultiSelectionViewController.swift index 14c7da0..29af2f0 100644 --- a/SwiftMultiSelect/MultiSelectionViewController.swift +++ b/SwiftMultiSelect/MultiSelectionViewController.swift @@ -40,7 +40,7 @@ class MultiSelecetionViewController: UIViewController,UIGestureRecognizerDelegat //Build layout let layout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) - layout.scrollDirection = UICollectionViewScrollDirection.horizontal + layout.scrollDirection = UICollectionView.ScrollDirection.horizontal layout.minimumInteritemSpacing = 0 layout.minimumLineSpacing = 0 @@ -149,14 +149,14 @@ class MultiSelecetionViewController: UIViewController,UIGestureRecognizerDelegat //constraint for stackview let stackView_H = NSLayoutConstraint.constraints( withVisualFormat: "H:|-0-[stackView]-0-|", - options: NSLayoutFormatOptions(rawValue: 0), + options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: nil, views: viewsDictionary ) //constraint for stackview let stackView_V = NSLayoutConstraint.constraints( withVisualFormat: "V:|-\(navBarHeight)-[stackView]-0-|", - options: NSLayoutFormatOptions(rawValue:0), + options: NSLayoutConstraint.FormatOptions(rawValue:0), metrics: nil, views: viewsDictionary ) diff --git a/SwiftMultiSelectExample/Pods/Pods.xcodeproj/project.pbxproj b/SwiftMultiSelectExample/Pods/Pods.xcodeproj/project.pbxproj index 60cc37a..e69601e 100644 --- a/SwiftMultiSelectExample/Pods/Pods.xcodeproj/project.pbxproj +++ b/SwiftMultiSelectExample/Pods/Pods.xcodeproj/project.pbxproj @@ -40,18 +40,18 @@ 0A092B2402E853C071F4ABBAA6C2865B /* CustomCollectionCell.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CustomCollectionCell.swift; sourceTree = ""; }; 0D4E1F52F6E76EBC962D45A4F6138BF4 /* CustomTableCell.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CustomTableCell.swift; sourceTree = ""; }; 2C670599C8E81C659808C1AA4D0C62A9 /* MultiSelectionTableView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MultiSelectionTableView.swift; sourceTree = ""; }; - 35808EFB77EF2AD67B563C9A79ADCFBD /* SwiftMultiSelect.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SwiftMultiSelect.framework; path = SwiftMultiSelect.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 3E86947696A89CD08681349A69329CA4 /* SwiftMultiSelect.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = SwiftMultiSelect.modulemap; sourceTree = ""; }; + 35808EFB77EF2AD67B563C9A79ADCFBD /* SwiftMultiSelect.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftMultiSelect.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3E86947696A89CD08681349A69329CA4 /* SwiftMultiSelect.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = SwiftMultiSelect.modulemap; sourceTree = ""; }; 405344B388FA45BC823142D1A154D423 /* Pods-SwiftMultiSelectExample-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SwiftMultiSelectExample-frameworks.sh"; sourceTree = ""; }; 5281FEF3930C2EF140B09CCC8D451E90 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52C6B06BE06DABCF45ED0D9191D244E3 /* Assets.xcassets */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 547CA702E55560018EF85DBD60C6666B /* ContactsLibrary.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ContactsLibrary.swift; sourceTree = ""; }; 5951048D102AABD7FC14240F8517497B /* SwiftMultiSelect.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SwiftMultiSelect.swift; sourceTree = ""; }; - 5E471611BE134725EDD835EF8ACFAE77 /* Pods-SwiftMultiSelectExample.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-SwiftMultiSelectExample.modulemap"; sourceTree = ""; }; + 5E471611BE134725EDD835EF8ACFAE77 /* Pods-SwiftMultiSelectExample.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-SwiftMultiSelectExample.modulemap"; sourceTree = ""; }; 625F3DC744055124C9CBDF9382061C73 /* SwiftMultiSelect-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SwiftMultiSelect-dummy.m"; sourceTree = ""; }; 64282000BE654C78F4BEB0D224B440DA /* SwiftMultiSelect-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftMultiSelect-prefix.pch"; sourceTree = ""; }; - 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - A96F631BD152F1A3E12B03F55396C78C /* Pods_SwiftMultiSelectExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_SwiftMultiSelectExample.framework; path = "Pods-SwiftMultiSelectExample.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + A96F631BD152F1A3E12B03F55396C78C /* Pods_SwiftMultiSelectExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftMultiSelectExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; AB828CAC30C41B9B44CD1E551E24346F /* Pods-SwiftMultiSelectExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwiftMultiSelectExample.release.xcconfig"; sourceTree = ""; }; ADB83487D503902B865864A56F0D2873 /* Pods-SwiftMultiSelectExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwiftMultiSelectExample.debug.xcconfig"; sourceTree = ""; }; B63C6A64CF66340668996F78DA6BB482 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -92,7 +92,6 @@ children = ( B804A8F33B9CFE20D8C5AFB829671757 /* Assets */, ); - name = SwiftMultiSelect; path = SwiftMultiSelect; sourceTree = ""; }; @@ -194,7 +193,6 @@ E9D4F9928BCE0C561E7FD3C26AB2C4E0 /* MultiSelectionViewController.swift */, 5951048D102AABD7FC14240F8517497B /* SwiftMultiSelect.swift */, ); - name = SwiftMultiSelect; path = SwiftMultiSelect; sourceTree = ""; }; @@ -212,7 +210,6 @@ children = ( 52C6B06BE06DABCF45ED0D9191D244E3 /* Assets.xcassets */, ); - name = Assets; path = Assets; sourceTree = ""; }; @@ -289,14 +286,15 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 1020; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 7DB346D0F39D3F0E887471402A8071AB; productRefGroup = 8B3A8F35F9C479EB7193FB958E4E6316 /* Products */; @@ -387,7 +385,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -398,28 +396,39 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_RELEASE=1", "$(inherited)", @@ -466,7 +475,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -505,7 +514,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -516,29 +525,40 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_DEBUG=1", @@ -589,7 +609,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/SwiftMultiSelectExample/Pods/Pods.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist b/SwiftMultiSelectExample/Pods/Pods.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..88376bb --- /dev/null +++ b/SwiftMultiSelectExample/Pods/Pods.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + Pods-SwiftMultiSelectExample.xcscheme_^#shared#^_ + + orderHint + 1 + + SwiftMultiSelect.xcscheme_^#shared#^_ + + orderHint + 2 + + + + diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/project.pbxproj b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/project.pbxproj index 2e318ea..cab88c8 100644 --- a/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/project.pbxproj +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/project.pbxproj @@ -118,19 +118,18 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Luca Becchetti"; TargetAttributes = { B1C3BCC71F2B2B2600904FA3 = { CreatedOnToolsVersion = 8.3.2; - DevelopmentTeam = 3NJYMZCH8Y; ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = B1C3BCC31F2B2B2600904FA3 /* Build configuration list for PBXProject "SwiftMultiSelectExample" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -243,21 +242,30 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -286,7 +294,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -294,21 +302,30 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -329,7 +346,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -339,13 +356,13 @@ baseConfigurationReference = A8F4428936230C1B080F6F03 /* Pods-SwiftMultiSelectExample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 3NJYMZCH8Y; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SwiftMultiSelectExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = it.brokenice.SwiftMultiSelectExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -354,13 +371,13 @@ baseConfigurationReference = 82EE9FC18253E00CEA25297C /* Pods-SwiftMultiSelectExample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 3NJYMZCH8Y; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SwiftMultiSelectExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = it.brokenice.SwiftMultiSelectExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..0921fdb --- /dev/null +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcodeproj/xcuserdata/rico.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + SwiftMultiSelectExample.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample/AppDelegate.swift b/SwiftMultiSelectExample/SwiftMultiSelectExample/AppDelegate.swift index 3130423..b18c660 100644 --- a/SwiftMultiSelectExample/SwiftMultiSelectExample/AppDelegate.swift +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/SwiftMultiSelectExample/SwiftMultiSelectExample/Assets.xcassets/AppIcon.appiconset/Contents.json index 415a4a5..c7885ed 100755 --- a/SwiftMultiSelectExample/SwiftMultiSelectExample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -92,6 +92,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { From 4046251273313a088fd6013fb4f955c39897b67f Mon Sep 17 00:00:00 2001 From: Rico237 Date: Sun, 23 Jun 2019 14:42:12 +0200 Subject: [PATCH 2/7] Add iPhoneX support --- SwiftMultiSelect/MultiSelectionViewController.swift | 8 +++++++- SwiftMultiSelect/SwiftMultiSelect.swift | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/SwiftMultiSelect/MultiSelectionViewController.swift b/SwiftMultiSelect/MultiSelectionViewController.swift index 29af2f0..5e8a8cd 100644 --- a/SwiftMultiSelect/MultiSelectionViewController.swift +++ b/SwiftMultiSelect/MultiSelectionViewController.swift @@ -161,7 +161,13 @@ class MultiSelecetionViewController: UIViewController,UIGestureRecognizerDelegat views: viewsDictionary ) - searchBar.topAnchor.constraint(equalTo: stackView.topAnchor, constant: 0).isActive = true + // Test if has notch + if (UIApplication.isDeviceWithSafeArea) { + searchBar.topAnchor.constraint(equalTo: stackView.topAnchor, constant: 25).isActive = true + } else { + searchBar.topAnchor.constraint(equalTo: stackView.topAnchor, constant: 0).isActive = true + } + searchBar.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0).isActive = true searchBar.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0).isActive = true searchBar.heightAnchor.constraint(equalToConstant: CGFloat(40)).isActive = true diff --git a/SwiftMultiSelect/SwiftMultiSelect.swift b/SwiftMultiSelect/SwiftMultiSelect.swift index 854c36a..c4defeb 100644 --- a/SwiftMultiSelect/SwiftMultiSelect.swift +++ b/SwiftMultiSelect/SwiftMultiSelect.swift @@ -340,5 +340,16 @@ extension UIImageView{ } } - +extension UIApplication { + + static var isDeviceWithSafeArea:Bool { + if #available(iOS 11.0, *) { + if let topPadding = shared.keyWindow?.safeAreaInsets.bottom, + topPadding > 0 { + return true + } + } + return false + } +} From d7aec28691817fe2bca246df598358a21ea2ca7b Mon Sep 17 00:00:00 2001 From: Herrick Wolber Date: Sun, 23 Jun 2019 14:43:58 +0200 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6de2b2d..79fb632 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Try our demo on [appetize.io](https://appetize.io/embed/4zz7rwje6npp03d8u8d8a75q ## Requirements - iOS 9+ - - swift 3.0 + - swift 5.0 - Access for Contacts ## Main features From 4bd88a1e184ed598fa262130cb71101f576dd07f Mon Sep 17 00:00:00 2001 From: Herrick Wolber Date: Sun, 23 Jun 2019 14:48:52 +0200 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79fb632..add3e8a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ SwiftMultiSelect

-[![Version](https://img.shields.io/badge/pod-0.2.4-blue.svg)](https://cocoapods.org/pods/InAppNotify) [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://cocoapods.org/pods/InAppNotify) [![Platform](https://img.shields.io/badge/platform-ios-lightgrey.svg)](https://cocoapods.org/pods/InAppNotify) [![Swift3](https://img.shields.io/badge/swift3-compatible-brightgreen.svg)](https://cocoapods.org/pods/InAppNotify) +[![Version](https://img.shields.io/badge/pod-0.2.4-blue.svg)](https://cocoapods.org/pods/SwiftMultiSelect) [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://cocoapods.org/pods/SwiftMultiSelect) [![Platform](https://img.shields.io/badge/platform-ios-lightgrey.svg)](https://cocoapods.org/pods/SwiftMultiSelect) [![Swift5](https://img.shields.io/badge/swift5-compatible-brightgreen.svg)](https://cocoapods.org/pods/SwiftMultiSelect) During develop of my apps, i usually needed to select more than one element from a tableview, but i don't like the native ios integration, i think is not graphically clear, so, i created this library. Choose SwiftMultiSelect for your next project, I'll be happy to give you a little help! From a0311cd36c48b11e199964a396303fdce0df0016 Mon Sep 17 00:00:00 2001 From: Rico237 Date: Sun, 23 Jun 2019 16:10:54 +0200 Subject: [PATCH 5/7] Fix size item and remove space --- SwiftMultiSelect/MultiSelectionViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SwiftMultiSelect/MultiSelectionViewController.swift b/SwiftMultiSelect/MultiSelectionViewController.swift index 5e8a8cd..9d63571 100644 --- a/SwiftMultiSelect/MultiSelectionViewController.swift +++ b/SwiftMultiSelect/MultiSelectionViewController.swift @@ -43,6 +43,7 @@ class MultiSelecetionViewController: UIViewController,UIGestureRecognizerDelegat layout.scrollDirection = UICollectionView.ScrollDirection.horizontal layout.minimumInteritemSpacing = 0 layout.minimumLineSpacing = 0 + layout.itemSize = CGSize(width: CGFloat(Config.selectorStyle.selectionHeight),height: CGFloat(Config.selectorStyle.selectionHeight)); //Build collectin view let selected = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout) @@ -155,7 +156,7 @@ class MultiSelecetionViewController: UIViewController,UIGestureRecognizerDelegat ) //constraint for stackview let stackView_V = NSLayoutConstraint.constraints( - withVisualFormat: "V:|-\(navBarHeight)-[stackView]-0-|", + withVisualFormat: "V:|-[stackView]-0-|", options: NSLayoutConstraint.FormatOptions(rawValue:0), metrics: nil, views: viewsDictionary From d7601bc633f020f7d9f25a72a9c6aa6dbebb684a Mon Sep 17 00:00:00 2001 From: Rico237 Date: Fri, 11 Oct 2019 00:54:22 +0200 Subject: [PATCH 6/7] Add maximum of selected items feature Can be found in Config. * -1 value means false (don't use it) * other value means true (then compared before adding items to selection) --- .../MultiSelectionTableView.swift | 41 +++++++++++-------- SwiftMultiSelect/SwiftMultiSelect.swift | 11 +++-- .../ViewController.swift | 5 +++ 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/SwiftMultiSelect/MultiSelectionTableView.swift b/SwiftMultiSelect/MultiSelectionTableView.swift index f634938..0b82886 100644 --- a/SwiftMultiSelect/MultiSelectionTableView.swift +++ b/SwiftMultiSelect/MultiSelectionTableView.swift @@ -160,7 +160,7 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc if SwiftMultiSelect.dataSourceType == .phone{ item = (searchString == "") ? SwiftMultiSelect.items![indexPath.row] : SwiftMultiSelect.items!.filter({$0.title.lowercased().contains(searchString.lowercased()) || ($0.description != nil && $0.description!.lowercased().contains(searchString.lowercased())) })[indexPath.row] - }else{ + } else { //Try to get item from delegate item = SwiftMultiSelect.dataSource?.swiftMultiSelect(itemAtRow: indexPath.row) } @@ -169,8 +169,7 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc item.color = cell.initials.backgroundColor! //Check if cell is already selected or not - if cell.accessoryType == UITableViewCell.AccessoryType.checkmark - { + if cell.accessoryType == UITableViewCell.AccessoryType.checkmark { //Set accessory type cell.accessoryType = UITableViewCell.AccessoryType.none @@ -181,20 +180,30 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc //Reload collectionview self.reloadAndPositionScroll(idp: item.row!, remove:true) - } - else{ - - //Set accessory type - cell.accessoryType = UITableViewCell.AccessoryType.checkmark + } else { - //Add current item to selected - selectedItems.append(item) + if Config.maxSelectItems != -1 && selectedItems.count >= Config.maxSelectItems - 1 { + + //Max number reached + SwiftMultiSelect.delegate?.numberMaximumOfItemsReached(items: selectedItems) + + } - //Comunicate selection to delegate - SwiftMultiSelect.delegate?.swiftMultiSelect(didSelectItem: item) - - //Reload collectionview - self.reloadAndPositionScroll(idp: item.row!, remove:false) + if Config.maxSelectItems == -1 || selectedItems.count < Config.maxSelectItems { //Default value = -1 + + //Set accessory type + cell.accessoryType = UITableViewCell.AccessoryType.checkmark + + //Add current item to selected + selectedItems.append(item) + + //Comunicate selection to delegate + SwiftMultiSelect.delegate?.swiftMultiSelect(didSelectItem: item) + + //Reload collectionview + self.reloadAndPositionScroll(idp: item.row!, remove:false) + + } } @@ -219,7 +228,7 @@ extension MultiSelecetionViewController:UITableViewDelegate,UITableViewDataSourc func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { self.searchString = searchText - if (searchText.isEmpty) { + if searchText.isEmpty { self.perform(#selector(self.hideKeyboardWithSearchBar(_:)), with: searchBar, afterDelay: 0) self.searchString = "" } diff --git a/SwiftMultiSelect/SwiftMultiSelect.swift b/SwiftMultiSelect/SwiftMultiSelect.swift index c4defeb..c7ebe55 100644 --- a/SwiftMultiSelect/SwiftMultiSelect.swift +++ b/SwiftMultiSelect/SwiftMultiSelect.swift @@ -93,13 +93,15 @@ public class SwiftMultiSelect{ /// Public struct for configuration and customizations public struct Config { - + + /// Number max of items that can be selected. Initial value -1 = set to false, others = true + public static var maxSelectItems : Int = -1 /// Background of main view public static var mainBackground : UIColor = UIColor.white /// View's title public static var viewTitle : String = "Swift Multiple Select" /// Title for done button - public static var doneString : String = "Done" + public static var doneString : String = "Valider" //Placeholder image during lazy load public static var placeholder_image : UIImage = SwiftMultiSelect.image(named: "user_blank")! /// Array of colors to use in initials @@ -298,13 +300,14 @@ public protocol SwiftMultiSelectDelegate{ /// Tell to delegate that item has been unselected func swiftMultiSelect(didUnselectItem item:SwiftMultiSelectItem) + /// Tell to delegate that the number of item selected has been reached + func numberMaximumOfItemsReached(items: [SwiftMultiSelectItem]) + /// Tell to delegate user has closed without select func didCloseSwiftMultiSelect() /// Tell to delegate user has closed without select func userDidSearch(searchString:String) - - } // MARK: - UIImageView diff --git a/SwiftMultiSelectExample/SwiftMultiSelectExample/ViewController.swift b/SwiftMultiSelectExample/SwiftMultiSelectExample/ViewController.swift index 086dfc6..01e79ad 100755 --- a/SwiftMultiSelectExample/SwiftMultiSelectExample/ViewController.swift +++ b/SwiftMultiSelectExample/SwiftMultiSelectExample/ViewController.swift @@ -28,6 +28,7 @@ class ViewController: UIViewController,SwiftMultiSelectDelegate,SwiftMultiSelect createItems() Config.doneString = "Ok" + Config.maxSelectItems = 3 SwiftMultiSelect.dataSource = self SwiftMultiSelect.delegate = self } @@ -97,6 +98,10 @@ class ViewController: UIViewController,SwiftMultiSelectDelegate,SwiftMultiSelect func swiftMultiSelect(didSelectItem item: SwiftMultiSelectItem) { print("item: \(item.title) has been selected!") } + + func numberMaximumOfItemsReached(items: [SwiftMultiSelectItem]) { + print("Maximum of \(Config.maxSelectItems.self) reached with items: \n\t\(items)") + } func didCloseSwiftMultiSelect() { badge.isHidden = true From 46aa7c1e87d18b4af3e8457867deb91e36bc00d0 Mon Sep 17 00:00:00 2001 From: Rico237 Date: Fri, 11 Oct 2019 01:01:22 +0200 Subject: [PATCH 7/7] Add all .DS_Store files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store