. :
http://thejustinwalsh.com/objective-c/tvml/2015/09/20/tvml-without-the-webserver.html
objective-c, Swift.
:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
let appControllerContext = TVApplicationControllerContext()
if let javaScriptURL = NSBundle.mainBundle().URLForResource("application", withExtension: "js"){
appControllerContext.javaScriptApplicationURL = javaScriptURL
}
let TVBaseURL = appControllerContext.javaScriptApplicationURL.URLByDeletingLastPathComponent
appControllerContext.launchOptions["BASEURL"] = TVBaseURL?.absoluteString
if let launchOptions = launchOptions as? [String: AnyObject] {
for (kind, value) in launchOptions {
appControllerContext.launchOptions[kind] = value
}
}
appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)
return true
}
: TVJS, .
Application.js:
App.onLaunch = function(options) {
var javascriptFiles = [
`${options.BASEURL}js/ResourceLoader.js`,
`${options.BASEURL}js/Presenter.js`
];
...
:
App.onLaunch = function(options) {
var javascriptFiles = [
`${options.BASEURL}ResourceLoader.js`,
`${options.BASEURL}Presenter.js`
];
...
:
${options.BASEURL}templates/Index.xml.js
:
${options.BASEURL}Index.xml.js
[]
Swift 3
: application.js ; .
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let appControllerContext = TVApplicationControllerContext()
if let javaScriptURL = Bundle.main.url(forResource: "application", withExtension: "js"){
appControllerContext.javaScriptApplicationURL = javaScriptURL
}
let TVBaseURL = appControllerContext.javaScriptApplicationURL.deletingLastPathComponent()
appControllerContext.launchOptions["BASEURL"] = TVBaseURL.absoluteString
if let launchOptions = launchOptions {
for (kind, value) in launchOptions {
appControllerContext.launchOptions[kind.rawValue] = value
}
}
appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)
return true
}