Skip to content

Commit 9cb80c8

Browse files
committed
Update syntax to Swift 5
1 parent 2ccce5c commit 9cb80c8

15 files changed

+31
-43
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode9.2
2+
osx_image: xcode10.3
33
cache:
44
bundler: true
55
directories:

iCookTV.xcodeproj/project.pbxproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@
773773
OTHER_SWIFT_FLAGS = "-D DEBUG";
774774
SDKROOT = appletvos;
775775
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
776-
SWIFT_VERSION = 3.0;
776+
SWIFT_VERSION = 5.0;
777777
TARGETED_DEVICE_FAMILY = 3;
778778
TVOS_DEPLOYMENT_TARGET = 9.0;
779779
};
@@ -817,7 +817,7 @@
817817
OTHER_SWIFT_FLAGS = "-D TRACKING";
818818
SDKROOT = appletvos;
819819
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
820-
SWIFT_VERSION = 3.0;
820+
SWIFT_VERSION = 5.0;
821821
TARGETED_DEVICE_FAMILY = 3;
822822
TVOS_DEPLOYMENT_TARGET = 9.0;
823823
VALIDATE_PRODUCT = YES;
@@ -836,7 +836,6 @@
836836
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
837837
PRODUCT_BUNDLE_IDENTIFIER = com.thepolydice.icook;
838838
PRODUCT_NAME = iCookTV;
839-
SWIFT_VERSION = 3.0;
840839
};
841840
name = Debug;
842841
};
@@ -853,7 +852,6 @@
853852
PRODUCT_BUNDLE_IDENTIFIER = com.thepolydice.icook;
854853
PRODUCT_NAME = iCookTV;
855854
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
856-
SWIFT_VERSION = 3.0;
857855
};
858856
name = Release;
859857
};
@@ -868,7 +866,6 @@
868866
PRODUCT_BUNDLE_IDENTIFIER = io.github.bcylin.iCookTVTests;
869867
PRODUCT_MODULE_NAME = iCookTVTests;
870868
PRODUCT_NAME = iCookTV;
871-
SWIFT_VERSION = 3.0;
872869
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iCookTV.app/iCookTV";
873870
};
874871
name = Debug;
@@ -885,7 +882,6 @@
885882
PRODUCT_MODULE_NAME = iCookTVTests;
886883
PRODUCT_NAME = iCookTV;
887884
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
888-
SWIFT_VERSION = 3.0;
889885
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iCookTV.app/iCookTV";
890886
};
891887
name = Release;

iCookTV/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3232

3333
var window: UIWindow?
3434
let tabBarController = UITabBarController()
35-
private var backgroundTask = UIBackgroundTaskInvalid
35+
private var backgroundTask = UIBackgroundTaskIdentifier.invalid
3636

3737
// MARK: - UIApplicationDelegate
3838

39-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
39+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4040
GroundControl.sync()
4141
Tracker.setUpAnalytics()
4242

@@ -67,7 +67,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6767

6868
private func endBackgroundTask(inApplication application: UIApplication) {
6969
application.endBackgroundTask(backgroundTask)
70-
backgroundTask = UIBackgroundTaskInvalid
70+
backgroundTask = UIBackgroundTaskIdentifier.invalid
7171
}
7272

7373
}

iCookTV/Controllers/LaunchViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LaunchViewController: UIViewController, DataFetching {
3737
}()
3838

3939
private lazy var activityIndicator: UIActivityIndicatorView = {
40-
let _indicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
40+
let _indicator = UIActivityIndicatorView(style: .whiteLarge)
4141
_indicator.color = UIColor.Palette.GreyishBrown
4242
_indicator.hidesWhenStopped = true
4343
return _indicator

iCookTV/Controllers/VideoPlayerController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VideoPlayerController: AVPlayerViewController, Trackable {
3535

3636
/// An activity indicator displayed before the player item is ready.
3737
private lazy var loadingIndicator: UIActivityIndicatorView = {
38-
let _indicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
38+
let _indicator = UIActivityIndicatorView(style: .whiteLarge)
3939
_indicator.hidesWhenStopped = true
4040
return _indicator
4141
}()

iCookTV/Controllers/VideosViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class VideosViewController: UIViewController,
160160
]
161161
}
162162

163-
func updateBackground(with image: UIImage?) {
163+
@objc func updateBackground(with image: UIImage?) {
164164
animateBackgroundTransition(to: image)
165165
}
166166

iCookTV/Extensions/Video+PlayerItem.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ extension Video {
4949

5050
private var titleMetaData: AVMetadataItem {
5151
let _title = AVMutableMetadataItem()
52-
_title.key = AVMetadataCommonKeyTitle as (NSCopying & NSObjectProtocol)?
53-
_title.keySpace = AVMetadataKeySpaceCommon
52+
_title.key = AVMetadataKey.commonKeyTitle as (NSCopying & NSObjectProtocol)?
53+
_title.keySpace = .common
5454
_title.locale = Locale.current
5555
_title.value = title as (NSCopying & NSObjectProtocol)?
5656
return _title
5757
}
5858

5959
private var descriptionMetaData: AVMetadataItem {
6060
let _description = AVMutableMetadataItem()
61-
_description.key = AVMetadataCommonKeyDescription as (NSCopying & NSObjectProtocol)?
62-
_description.keySpace = AVMetadataKeySpaceCommon
61+
_description.key = AVMetadataKey.commonKeyDescription as (NSCopying & NSObjectProtocol)?
62+
_description.keySpace = .common
6363
_description.locale = Locale.current
6464
_description.value = (description ?? "")
6565
.components(separatedBy: CharacterSet.newlines)
@@ -106,10 +106,10 @@ private extension UIImage {
106106

107107
var metadataItem: AVMetadataItem {
108108
let _item = AVMutableMetadataItem()
109-
_item.key = AVMetadataCommonKeyArtwork as (NSCopying & NSObjectProtocol)?
110-
_item.keySpace = AVMetadataKeySpaceCommon
109+
_item.key = AVMetadataKey.commonKeyArtwork as (NSCopying & NSObjectProtocol)?
110+
_item.keySpace = .common
111111
_item.locale = Locale.current
112-
_item.value = UIImageJPEGRepresentation(self, UIImage.JPEGLeastCompressionQuality) as (NSCopying & NSObjectProtocol)?
112+
_item.value = jpegData(compressionQuality: UIImage.JPEGLeastCompressionQuality) as (NSCopying & NSObjectProtocol)?
113113
return _item
114114
}
115115

iCookTV/Helpers/HistoryManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct HistoryManager {
6666
Debug.print(path)
6767

6868
let decoder = JSONDecoder()
69-
var records: [Video] = history.flatMap { try? decoder.decode(Video.self, from: $0) }
69+
var records: [Video] = history.compactMap { try? decoder.decode(Video.self, from: $0) }
7070

7171
// Keep the latest video at top.
7272
records = records.filter { $0.id != video.id }

iCookTV/Models/DataSource.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ class DataSource<Collection: DataCollection>: NSObject, SourceType {
3838

3939
private(set) var dataCollection: Collection
4040

41+
var numberOfItems: Int {
42+
return dataCollection.count
43+
}
44+
45+
subscript(index: Int) -> Collection.DataType {
46+
return dataCollection[index]
47+
}
48+
4149
// MARK: - UICollectionViewDataSource
4250

4351
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

iCookTV/Models/SourceType.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,3 @@ protocol SourceType: UICollectionViewDataSource {
3535

3636
subscript(index: Int) -> Collection.DataType { get }
3737
}
38-
39-
40-
////////////////////////////////////////////////////////////////////////////////
41-
42-
43-
extension SourceType {
44-
45-
var numberOfItems: Int {
46-
return dataCollection.count
47-
}
48-
49-
subscript(index: Int) -> Collection.DataType {
50-
return dataCollection[index]
51-
}
52-
53-
}

0 commit comments

Comments
 (0)