Skip to content

Commit

Permalink
Migrate Swift to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
radyslavkrechet committed Apr 18, 2019
1 parent 5abf319 commit 31fba97
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 112 deletions.
3 changes: 0 additions & 3 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ target 'ShopApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

pod 'ShopApp_Shopify', :path => '../ShopAppShopify'
pod 'ShopApp_Gateway', :path => '.'

# DI
pod 'Swinject', '~> 2.6'
pod 'SwinjectStoryboard', '~> 2.2'
Expand Down
29 changes: 2 additions & 27 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
PODS:
- Alamofire (4.8.2)
- AvatarImageView (2.2.0)
- CoreStore (6.3.1)
- Crashlytics (3.12.0):
- Fabric (~> 1.9.0)
- DropDown (2.3.13)
- Fabric (1.9.0)
- KeychainSwift (14.0.0)
- MBProgressHUD (1.1.0)
- Mobile-Buy-SDK (3.1.5)
- Nimble (8.0.1)
- Quick (2.0.0)
- RxCocoa (4.5.0):
Expand All @@ -17,12 +14,6 @@ PODS:
- SDWebImage (5.0.1):
- SDWebImage/Core (= 5.0.1)
- SDWebImage/Core (5.0.1)
- ShopApp_Gateway (1.0.5)
- ShopApp_Shopify (1.0.5):
- Alamofire (~> 4.8)
- KeychainSwift (~> 14.0)
- Mobile-Buy-SDK (= 3.1.5)
- ShopApp_Gateway (~> 1.0)
- SKPhotoBrowser (6.1.0)
- SwiftLint (0.31.0)
- Swinject (2.6.0)
Expand All @@ -47,8 +38,6 @@ DEPENDENCIES:
- RxCocoa (~> 4.5)
- RxSwift (~> 4.5)
- SDWebImage (~> 5.0)
- ShopApp_Gateway (from `.`)
- ShopApp_Shopify (from `../ShopAppShopify`)
- SKPhotoBrowser (~> 6.1)
- SwiftLint (~> 0.31)
- Swinject (~> 2.6)
Expand All @@ -62,15 +51,12 @@ DEPENDENCIES:

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Alamofire
- AvatarImageView
- CoreStore
- Crashlytics
- DropDown
- Fabric
- KeychainSwift
- MBProgressHUD
- Mobile-Buy-SDK
- Nimble
- Quick
- RxCocoa
Expand All @@ -87,29 +73,18 @@ SPEC REPOS:
- "UIImage+Additions"
- UIScrollView-InfiniteScroll

EXTERNAL SOURCES:
ShopApp_Gateway:
:path: "."
ShopApp_Shopify:
:path: "../ShopAppShopify"

SPEC CHECKSUMS:
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
AvatarImageView: afe8e7eb50181ca3f095e21034f245676b535c55
CoreStore: 1ce7b77a95f0939d90b2d1e04e66a4a5bc1614d7
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
DropDown: 8a2116376c1981888557f72ec2ffc9a5e0e456ec
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
KeychainSwift: d3cce449feb5198907aa3c50ae7409fdbd9d3e20
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
Mobile-Buy-SDK: ea84d7635b110fddffe37a445c020fc0c5e5a8d3
Nimble: 45f786ae66faa9a709624227fae502db55a8bdd0
Quick: ce1276c7c27ba2da3cb2fd0cde053c3648b3b22d
RxCocoa: cbf70265dc65a981d4ac982e513c10cf23df24a0
RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
SDWebImage: 27dd2c9ea07a2252f94557c9fbb6105ee94b74c9
ShopApp_Gateway: 2a12ae778507160df36272e69c2d9db2b27b1ec5
ShopApp_Shopify: d1b0cd328df8ee5aabce22bfcf04f1959cd3c7e7
SKPhotoBrowser: 343de95d89dc7913763c5dda243cc6e606e4a168
SwiftLint: 7a0227733d786395817373b2d0ca799fd0093ff3
Swinject: 48a96cda93633cf2860697b4ce76ab5db9ebaca2
Expand All @@ -121,6 +96,6 @@ SPEC CHECKSUMS:
"UIImage+Additions": da531911c34e298b46b567a28df03bb098af1389
UIScrollView-InfiniteScroll: 3ef456bcbe759c19f510a383cff96e6647c98c98

PODFILE CHECKSUM: 9ba3f9a2a4e496b4cf04d83e7e58c38718f55ce4
PODFILE CHECKSUM: cd48f962b8e674f6e6f890a410a36d880aa28fb0

COCOAPODS: 1.6.1
COCOAPODS: 1.7.0.beta.3
48 changes: 12 additions & 36 deletions ShopApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4321,19 +4321,14 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ShopApp/Pods-ShopApp-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
"${BUILT_PRODUCTS_DIR}/AvatarImageView/AvatarImageView.framework",
"${BUILT_PRODUCTS_DIR}/CoreStore/CoreStore.framework",
"${BUILT_PRODUCTS_DIR}/DropDown/DropDown.framework",
"${BUILT_PRODUCTS_DIR}/KeychainSwift/KeychainSwift.framework",
"${BUILT_PRODUCTS_DIR}/MBProgressHUD/MBProgressHUD.framework",
"${BUILT_PRODUCTS_DIR}/Mobile-Buy-SDK/MobileBuySDK.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SKPhotoBrowser/SKPhotoBrowser.framework",
"${BUILT_PRODUCTS_DIR}/ShopApp_Gateway/ShopApp_Gateway.framework",
"${BUILT_PRODUCTS_DIR}/ShopApp_Shopify/ShopApp_Shopify.framework",
"${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework",
"${BUILT_PRODUCTS_DIR}/SwipeCellKit/SwipeCellKit.framework",
Expand All @@ -4345,19 +4340,14 @@
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AvatarImageView.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CoreStore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DropDown.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MBProgressHUD.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MobileBuySDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SKPhotoBrowser.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ShopApp_Gateway.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ShopApp_Shopify.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwipeCellKit.framework",
Expand Down Expand Up @@ -4393,19 +4383,14 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ShopApp-ShopAppTests/Pods-ShopApp-ShopAppTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
"${BUILT_PRODUCTS_DIR}/AvatarImageView/AvatarImageView.framework",
"${BUILT_PRODUCTS_DIR}/CoreStore/CoreStore.framework",
"${BUILT_PRODUCTS_DIR}/DropDown/DropDown.framework",
"${BUILT_PRODUCTS_DIR}/KeychainSwift/KeychainSwift.framework",
"${BUILT_PRODUCTS_DIR}/MBProgressHUD/MBProgressHUD.framework",
"${BUILT_PRODUCTS_DIR}/Mobile-Buy-SDK/MobileBuySDK.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SKPhotoBrowser/SKPhotoBrowser.framework",
"${BUILT_PRODUCTS_DIR}/ShopApp_Gateway/ShopApp_Gateway.framework",
"${BUILT_PRODUCTS_DIR}/ShopApp_Shopify/ShopApp_Shopify.framework",
"${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework",
"${BUILT_PRODUCTS_DIR}/SwipeCellKit/SwipeCellKit.framework",
Expand All @@ -4419,19 +4404,14 @@
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AvatarImageView.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CoreStore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DropDown.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MBProgressHUD.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MobileBuySDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SKPhotoBrowser.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ShopApp_Gateway.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ShopApp_Shopify.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwipeCellKit.framework",
Expand Down Expand Up @@ -5111,7 +5091,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ShopApp.app/ShopApp";
};
Expand All @@ -5136,7 +5116,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ShopApp.app/ShopApp";
};
Expand All @@ -5159,7 +5139,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ShopApp.app/ShopApp";
};
Expand All @@ -5182,7 +5162,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ShopApp.app/ShopApp";
};
Expand Down Expand Up @@ -5251,7 +5231,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDB93E0BA4D55C68C0184D44 /* Pods-ShopApp.debug dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ShopApp/ShopApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -5264,7 +5243,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopApp.test.temp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = "Debug Dev";
};
Expand Down Expand Up @@ -5324,7 +5303,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F3BFB1F59606A336BF44AC60 /* Pods-ShopApp.release dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ShopApp/ShopApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -5337,7 +5315,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopApp.test.temp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = "Release Dev";
};
Expand Down Expand Up @@ -5456,7 +5434,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = EB0308B87E4D118F1B403D5C /* Pods-ShopApp.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ShopApp/ShopApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -5468,15 +5445,14 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopApp.test.temp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
61E4E6441F56C868001C6E01 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A08BE9C4EDA4D44357774F6F /* Pods-ShopApp.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ShopApp/ShopApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -5488,7 +5464,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.rubygarage.ShopApp.test.temp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -5515,7 +5491,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -5545,7 +5521,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -5573,7 +5549,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.rubygarage.ShopApp.ShopApp-Gateway";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -5601,7 +5577,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.rubygarage.ShopApp.ShopApp-Gateway";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
8 changes: 0 additions & 8 deletions ShopApp.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

This file was deleted.

4 changes: 2 additions & 2 deletions ShopApp/App/Helpers/HtmlStringMultimediaCompressor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ struct HtmlStringMultimediaCompressor {
let endRange = tail.range(of: kHtmlIframeCloseTag)!
let iframe = String(tail[..<endRange.lowerBound])
var iframeParts = iframe.split(separator: " ")
if let width = iframeParts.first(where: { $0.hasPrefix(kHtmlWidthPrefix) }), let index = iframeParts.index(of: width) {
if let width = iframeParts.first(where: { $0.hasPrefix(kHtmlWidthPrefix) }), let index = iframeParts.firstIndex(of: width) {
iframeParts.remove(at: index)
}
iframeParts.insert(Substring(String(format: kHtmlWidthFormat, width - kHtmlMarging)), at: 0)
if let height = iframeParts.first(where: { $0.hasPrefix(kHtmlHeightPrefix) }), let index = iframeParts.index(of: height) {
if let height = iframeParts.first(where: { $0.hasPrefix(kHtmlHeightPrefix) }), let index = iframeParts.firstIndex(of: height) {
iframeParts.remove(at: index)
}
iframeParts.insert(Substring(String(format: kHtmlHeightFormat, width / kHtmlIframeAspectRation)), at: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OrderDetailsViewController: BaseViewController<OrderDetailsViewModel>, Ord
// MARK: - Actions

@objc override func backButtonDidPress() {
guard let index = navigationController?.viewControllers.index(of: self), navigationController?.viewControllers[index - 1] is CheckoutSuccessViewController else {
guard let index = navigationController?.viewControllers.firstIndex(of: self), navigationController?.viewControllers[index - 1] is CheckoutSuccessViewController else {
navigationController?.popViewController(animated: true)
return
}
Expand Down
4 changes: 2 additions & 2 deletions ShopApp/App/Modules/Base/Views/BasePicker/BasePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BasePicker: PlaceholderedTextField, UIPickerViewDataSource, UIPickerViewDe
didSet {
pickerView.reloadAllComponents()
if let customData = customData, let text = text {
pickerView.selectRow(customData.index(of: text) ?? 0, inComponent: 0, animated: false)
pickerView.selectRow(customData.firstIndex(of: text) ?? 0, inComponent: 0, animated: false)
}
}
}
Expand All @@ -41,7 +41,7 @@ class BasePicker: PlaceholderedTextField, UIPickerViewDataSource, UIPickerViewDe
return
}
setPlaceholderPosition()
pickerView.selectRow(data.index(of: text) ?? 0, inComponent: 0, animated: false)
pickerView.selectRow(data.firstIndex(of: text) ?? 0, inComponent: 0, animated: false)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ShopApp/App/Modules/Cart/ViewModels/CartViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CartViewModel: BaseViewModel {
}

private func removeFromData(with item: CartProduct) {
guard let index = data.value.index(where: { $0.productId == item.productId }) else {
guard let index = data.value.firstIndex(where: { $0.productId == item.productId }) else {
return
}
data.value.remove(at: index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SortVariantsViewController: UIViewController, SortVariantsTableProviderDel
return
}
let sortingValue: SortingValue!
if let variant = variant, let index = SortingValue.allValues.index(of: variant) {
if let variant = variant, let index = SortingValue.allValues.firstIndex(of: variant) {
sortingValue = SortingValue(rawValue: index) ?? .name
} else {
sortingValue = .name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ProductDetailsViewModel: BaseViewModel {

func selectOption(with name: String, value: String) {
let selectedOptionsNames = selectedOptions.map({ $0.name })
if let index = selectedOptionsNames.index(of: name) {
if let index = selectedOptionsNames.firstIndex(of: name) {
selectedOptions[index].value = value
}
if let variants = product.value?.variants {
Expand Down
Loading

0 comments on commit 31fba97

Please sign in to comment.