 // MIT license. Copyright (c) 2018 SwiftyFORM. All rights reserved.
 import UIKit
+import WebKit
 
 public enum WhatToShow {
 	case json(json: Data)

	}

	public override func loadView() {
		let webview = UIWebView()
		self.view = webview

		let item = UIBarButtonItem(title: "Dismiss", style: .plain, target: self, action: #selector(DebugViewController.dismissAction(_:)))

		switch whatToShow {
		case let .json(json):
			let url = URL(string: "http://localhost")!
			webview.load(json, mimeType: "application/json", characterEncodingName: "utf-8", baseURL: url)
			self.title = "JSON"
		case let .text(text):
			let url = URL(string: "http://localhost")!
			let data = (text as NSString).data(using: String.Encoding.utf8.rawValue)!
			webview.load(data, mimeType: "text/plain", characterEncodingName: "utf-8", baseURL: url)
			self.title = "Text"
		case let .url(url):
			let request = URLRequest(url: url)
			webview.load(request)
			self.title = "URL"
		}
	}
