diff options
author | Justin Gluck <justin.gluck@livio.io> | 2019-03-14 10:33:58 -0400 |
---|---|---|
committer | Justin Gluck <justin.gluck@livio.io> | 2019-03-14 10:33:58 -0400 |
commit | dfa80bccd2ffdceba6c84476a7401461e03e6213 (patch) | |
tree | e93587b957f41991b9ff94db4a0813b9a3bdba98 /Example Apps | |
parent | 7c95663a41be9f065955c8f75a7c90e10bdad4ac (diff) | |
download | sdl_ios-dfa80bccd2ffdceba6c84476a7401461e03e6213.tar.gz |
Updating Swift 3 to swift 4.2
Diffstat (limited to 'Example Apps')
4 files changed, 11 insertions, 11 deletions
diff --git a/Example Apps/Example Swift/AppDelegate.swift b/Example Apps/Example Swift/AppDelegate.swift index fd42468d3..d602970c7 100644 --- a/Example Apps/Example Swift/AppDelegate.swift +++ b/Example Apps/Example Swift/AppDelegate.swift @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { AppUserDefaults.setDefaults() diff --git a/Example Apps/Example Swift/AudioManager.swift b/Example Apps/Example Swift/AudioManager.swift index a2e80929d..6ea7e8813 100644 --- a/Example Apps/Example Swift/AudioManager.swift +++ b/Example Apps/Example Swift/AudioManager.swift @@ -127,12 +127,12 @@ private extension AudioManager { /// /// - Parameter data: The audio data /// - Returns: An AVAudioPCMBuffer object - func createPCMBuffer(with data: Data) -> AVAudioPCMBuffer { + func createPCMBuffer(with data: Data) -> AVAudioPCMBuffer? { audioData?.append(data) - let audioFormat = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: false) + guard let audioFormat = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: false) else { return nil } let numFrames = UInt32(data.count) / (audioFormat.streamDescription.pointee.mBytesPerFrame) - let buffer = AVAudioPCMBuffer(pcmFormat: audioFormat, frameCapacity: numFrames) + guard let buffer = AVAudioPCMBuffer(pcmFormat: audioFormat, frameCapacity: numFrames) else { return nil } buffer.frameLength = numFrames let bufferChannels = buffer.int16ChannelData! let bufferDataCount = data.copyBytes(to: UnsafeMutableBufferPointer(start: bufferChannels[0], count: data.count)) diff --git a/Example Apps/Example Swift/ConnectionContainerViewController.swift b/Example Apps/Example Swift/ConnectionContainerViewController.swift index 431888dc9..4e6dd3895 100644 --- a/Example Apps/Example Swift/ConnectionContainerViewController.swift +++ b/Example Apps/Example Swift/ConnectionContainerViewController.swift @@ -69,16 +69,16 @@ class ConnectionContainerViewController: UIViewController { } // Mark: - View functions func removeFromView() { - let vc = self.childViewControllers.last + let vc = self.children.last vc?.view.removeFromSuperview() - vc?.removeFromParentViewController() + vc?.removeFromParent() } func loadChildViewController(index: Int?) { AppUserDefaults.shared.lastUsedSegment = index let initialViewController: UIViewController = viewControllers[index!] - self.addChildViewController(initialViewController) + self.addChild(initialViewController) view.addSubview(initialViewController.view) - initialViewController.didMove(toParentViewController: self) + initialViewController.didMove(toParent: self) } } diff --git a/Example Apps/Example Swift/VehicleDataManager.swift b/Example Apps/Example Swift/VehicleDataManager.swift index 08b2881c3..c5e2b187e 100644 --- a/Example Apps/Example Swift/VehicleDataManager.swift +++ b/Example Apps/Example Swift/VehicleDataManager.swift @@ -33,7 +33,7 @@ extension VehicleDataManager { /// Subscribes to odometer data. You must subscribe to a notification with name `SDLDidReceiveVehicleData` to get the new data when the odometer data changes. func subscribeToVehicleOdometer() { let subscribeToVehicleOdometer = SDLSubscribeVehicleData() - subscribeToVehicleOdometer.odometer = true + subscribeToVehicleOdometer.odometer = true as NSNumber & SDLBool sdlManager.send(request: subscribeToVehicleOdometer) { [unowned self] (request, response, error) in guard let result = response?.resultCode else { return } @@ -73,7 +73,7 @@ extension VehicleDataManager { /// Unsubscribes to vehicle odometer data. func unsubscribeToVehicleOdometer() { let unsubscribeToVehicleOdometer = SDLUnsubscribeVehicleData() - unsubscribeToVehicleOdometer.odometer = true + unsubscribeToVehicleOdometer.odometer = true as NSNumber & SDLBool sdlManager.send(request: unsubscribeToVehicleOdometer) { (request, response, error) in guard let response = response, response.resultCode == .success else { return } self.resetOdometer() @@ -83,7 +83,7 @@ extension VehicleDataManager { /// Notification containing the updated vehicle data. /// /// - Parameter notification: A SDLOnVehicleData notification - func vehicleDataNotification(_ notification: SDLRPCNotificationNotification) { + @objc func vehicleDataNotification(_ notification: SDLRPCNotificationNotification) { guard let handler = refreshUIHandler, let onVehicleData = notification.notification as? SDLOnVehicleData, let odometer = onVehicleData.odometer else { return } |