Swift 2からSwift 3に変換されたTVOSアプリがあり、次のエラーが発生しています。私はそれを沈黙させる方法が不明です。Swift 3 '[UIApplicationLaunchOptionsKey:Any]?' '[String:NSString]'に変換できません
'[UIApplicationLaunchOptionsKey:Any]?'
、コードのこの部分中に表示されてappControllerContext.launchOptions["BASEURL"] = AppDelegate.TVBaseURL
if let launchOptions = launchOptions as? [String: AnyObject] {
for (kind, value) in launchOptions {
appControllerContext.launchOptions[kind] = value
}
}
追加しました: '[NSStringの文字列]':に変換ない
/*
Copyright (C) 2015 Hani Hamrouni. All Rights Reserved.
*/
import UIKit
import TVMLKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, TVApplicationControllerDelegate {
// MARK: Properties
var window: UIWindow?
var appController: TVApplicationController?
//change the link to your host url
static let TVBaseURL = "http://google.com"
static let TVBootURL = "\(AppDelegate.TVBaseURL)js/application.js"
// MARK: UIApplication Overrides
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
/*
Create the TVApplicationControllerContext for this application
and set the properties that will be passed to the `App.onLaunch` function
in JavaScript.
*/
let appControllerContext = TVApplicationControllerContext()
/*
The JavaScript URL is used to create the JavaScript context for your
TVMLKit application. Although it is possible to separate your JavaScript
into separate files, to help reduce the launch time of your application
we recommend creating minified and compressed version of this resource.
This will allow for the resource to be retrieved and UI presented to
the user quickly.
*/
if let javaScriptURL = URL(string: AppDelegate.TVBootURL) {
appControllerContext.javaScriptApplicationURL = javaScriptURL
}
appControllerContext.launchOptions["BASEURL"] = AppDelegate.TVBaseURL
if let launchOptions = launchOptions {
for (kind, value) in launchOptions {
appControllerContext.launchOptions[kind.rawValue] = value as AnyObject
}
}
appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)
return true
}
// MARK: TVApplicationControllerDelegate
func appController(_ appController: TVApplicationController, didFinishLaunching options: [String: Any]?) {
print("\(#function) invoked with options: \(options)")
}
func appController(_ appController: TVApplicationController, didFail error: Error) {
print("\(#function) invoked with error: \(error)")
let title = "Error Launching Application"
//error message
let message = error.localizedDescription
let alertController = UIAlertController(title: title, message: message, preferredStyle:.alert)
self.appController?.navigationController.present(alertController, animated: true, completion: {() -> Void in
// ...
})
}
func appController(_ appController: TVApplicationController, didStop options: [String: Any]?) {
print("\(#function) invoked with options: \(options)")
}
}
'[String:AnyObject]'を '[NSObject:AnyObject]'に変更しようとしましたか? –
はい、私は、エラーを沈黙させません。 –