@@ -19,13 +19,14 @@ class ViewController: NSViewController {
19
19
override func viewDidLoad( ) {
20
20
super. viewDidLoad ( )
21
21
22
- for textView in [ templateTextView, JSONTextView] {
23
- textView. automaticQuoteSubstitutionEnabled = false ;
24
- textView. textStorage? . font = font
25
- }
22
+ templateTextView. isAutomaticQuoteSubstitutionEnabled = false
23
+ templateTextView. textStorage? . font = font
24
+
25
+ JSONTextView . isAutomaticQuoteSubstitutionEnabled = false
26
+ JSONTextView . textStorage? . font = font
26
27
}
27
28
28
- @IBAction func render( sender: AnyObject ) {
29
+ @IBAction func render( _ sender: Any ? ) {
29
30
do {
30
31
let template = try Template ( string: model. templateString)
31
32
@@ -42,17 +43,17 @@ class ViewController: NSViewController {
42
43
template. register ( StandardLibrary . URLEscape, forKey: " URLEscape " )
43
44
template. register ( StandardLibrary . javascriptEscape, forKey: " javascriptEscape " )
44
45
45
- let data = model. JSONString. dataUsingEncoding ( NSUTF8StringEncoding ) !
46
- let JSONObject : AnyObject = try NSJSONSerialization . JSONObjectWithData ( data, options: NSJSONReadingOptions ( ) )
46
+ let data = model. JSONString. data ( using : . utf8 ) !
47
+ let JSONObject = try JSONSerialization . jsonObject ( with : data, options: [ ] )
47
48
let string = try template. render ( Box ( JSONObject as? NSObject ) )
48
- presentRenderingString ( string)
49
+ present ( renderingString : string)
49
50
}
50
51
catch let error as NSError {
51
- presentRenderingString ( " \( error. domain) : \( error. localizedDescription) " )
52
+ present ( renderingString : " \( error. domain) : \( error. localizedDescription) " )
52
53
}
53
54
}
54
55
55
- func presentRenderingString ( string: String ) {
56
+ func present ( renderingString string: String ) {
56
57
self . renderingTextView. string = string
57
58
self . renderingTextView. textStorage? . font = font
58
59
}
0 commit comments