Skip to content

Commit e77844f

Browse files
authored
Merge pull request #81 from kazuhiro4949/feature/fix_warning
fix warning
2 parents 4a75d8a + 4899853 commit e77844f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

PagingKit.xcodeproj/project.pbxproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
};
187187
6EC140C31F0940F40054B514 = {
188188
CreatedOnToolsVersion = 8.3.3;
189+
LastSwiftMigration = 1010;
189190
ProvisioningStyle = Automatic;
190191
};
191192
};
@@ -441,7 +442,8 @@
441442
PRODUCT_BUNDLE_IDENTIFIER = kazuhiro.hayashi.PagingKitTests;
442443
PRODUCT_NAME = "$(TARGET_NAME)";
443444
PROVISIONING_PROFILE_SPECIFIER = "";
444-
SWIFT_VERSION = 3.0;
445+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
446+
SWIFT_VERSION = 4.2;
445447
};
446448
name = Debug;
447449
};
@@ -456,7 +458,8 @@
456458
PRODUCT_BUNDLE_IDENTIFIER = kazuhiro.hayashi.PagingKitTests;
457459
PRODUCT_NAME = "$(TARGET_NAME)";
458460
PROVISIONING_PROFILE_SPECIFIER = "";
459-
SWIFT_VERSION = 3.0;
461+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
462+
SWIFT_VERSION = 4.2;
460463
};
461464
name = Release;
462465
};

PagingKit/PagingMenuView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ open class PagingMenuView: UIScrollView {
459459
let currentOffset = contentOffset
460460
let contentWidth = contentSize.width
461461
let centerOffsetX = (contentWidth - bounds.size.width) / 2
462-
let distanceFromCenter = fabs(currentOffset.x - centerOffsetX)
462+
let distanceFromCenter = abs(currentOffset.x - centerOffsetX)
463463

464464
if distanceFromCenter > (contentWidth - bounds.size.width) / 4 {
465465
contentOffset = CGPoint(x: centerOffsetX, y: currentOffset.y)

PagingKitTests/PagingMenuViewControllerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ class PagingMenuViewControllerTests: XCTestCase {
132132

133133
menuViewController.reloadData()
134134

135-
let indices = menuViewController.visibleCells.flatMap { $0.index }
135+
let indices = menuViewController.visibleCells.compactMap { $0.index }
136136
let randamizedScrollOrder = (0..<10).map { _ in Int(arc4random_uniform(UInt32(indices.last ?? 0))) }
137137
var resultOrder = [Int?]()
138138
for i in randamizedScrollOrder {
139139
menuViewController.scroll(index: i, animated: false)
140140
resultOrder.append(menuViewController.currentFocusedCell?.index)
141141
}
142-
let actualScrollOrder = resultOrder.flatMap{ $0 }
142+
let actualScrollOrder = resultOrder.compactMap{ $0 }
143143
XCTAssertEqual(actualScrollOrder, randamizedScrollOrder, "focus correct cell")
144144
}
145145

PagingKitTests/PagingMenuViewTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class PagingMenuViewTests: XCTestCase {
146146
pagingMenuView.dataSource = dataSource
147147
pagingMenuView.reloadData()
148148

149-
let actualRects = (0..<dataSource.data.count).flatMap(pagingMenuView.rectForItem)
149+
let actualRects = (0..<dataSource.data.count).compactMap(pagingMenuView.rectForItem)
150150
let expectedRects = Array(stride(from: 0, to: 2000, by: 100)).map { CGRect(x: $0, y: 0, width: 100, height: 44) }
151151
XCTAssertEqual(actualRects,
152152
expectedRects, "get correct rect")
@@ -279,7 +279,7 @@ class PagingMenuViewTests: XCTestCase {
279279

280280
let cellIndice = pagingMenuView
281281
.visibleCells
282-
.flatMap(pagingMenuView.containerView.subviews.index(of:))
282+
.compactMap(pagingMenuView.containerView.subviews.index(of:))
283283

284284
let aboveIndices = cellIndice.filter { Int($0) > Int(focusViewIndex) }
285285
XCTAssertEqual(aboveIndices.count, 0, "focus view is in front of cell")
@@ -298,7 +298,7 @@ class PagingMenuViewTests: XCTestCase {
298298

299299
let cellIndice = pagingMenuView
300300
.visibleCells
301-
.flatMap(pagingMenuView.containerView.subviews.index(of:))
301+
.compactMap(pagingMenuView.containerView.subviews.index(of:))
302302

303303
let aboveIndices = cellIndice.filter { Int($0) > Int(focusViewIndex) }
304304
XCTAssertEqual(aboveIndices.count, 0, "focus view is in front of cell")

0 commit comments

Comments
 (0)