Skip to content

Commit c62ffa1

Browse files
committed
MustacheDemoOSX uses Swift 3
1 parent 147083a commit c62ffa1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

Docs/DemoApps/MustacheDemoOSX/MustacheDemoOSX.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
ONLY_ACTIVE_ARCH = YES;
394394
SDKROOT = macosx;
395395
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
396-
SWIFT_VERSION = 2.3;
396+
SWIFT_VERSION = 3.0;
397397
};
398398
name = Debug;
399399
};
@@ -433,7 +433,7 @@
433433
MTL_ENABLE_DEBUG_INFO = NO;
434434
SDKROOT = macosx;
435435
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
436-
SWIFT_VERSION = 2.3;
436+
SWIFT_VERSION = 3.0;
437437
};
438438
name = Release;
439439
};

Docs/DemoApps/MustacheDemoOSX/MustacheDemoOSX/ViewController.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ class ViewController: NSViewController {
1919
override func viewDidLoad() {
2020
super.viewDidLoad()
2121

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
2627
}
2728

28-
@IBAction func render(sender: AnyObject) {
29+
@IBAction func render(_ sender: Any?) {
2930
do {
3031
let template = try Template(string: model.templateString)
3132

@@ -42,17 +43,17 @@ class ViewController: NSViewController {
4243
template.register(StandardLibrary.URLEscape, forKey: "URLEscape")
4344
template.register(StandardLibrary.javascriptEscape, forKey: "javascriptEscape")
4445

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: [])
4748
let string = try template.render(Box(JSONObject as? NSObject))
48-
presentRenderingString(string)
49+
present(renderingString: string)
4950
}
5051
catch let error as NSError {
51-
presentRenderingString("\(error.domain): \(error.localizedDescription)")
52+
present(renderingString: "\(error.domain): \(error.localizedDescription)")
5253
}
5354
}
5455

55-
func presentRenderingString(string: String) {
56+
func present(renderingString string: String) {
5657
self.renderingTextView.string = string
5758
self.renderingTextView.textStorage?.font = font
5859
}

0 commit comments

Comments
 (0)