-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathViewController.swift
More file actions
40 lines (32 loc) · 1 KB
/
ViewController.swift
File metadata and controls
40 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// ViewController.swift
// Example
//
// Created by Alexander Schuch on 12/07/14.
// Copyright (c) 2014 Alexander Schuch. All rights reserved.
//
import UIKit
import AwesomeCache
class ViewController: UIViewController {
@IBOutlet var textView: UITextView!
let cache = try! Cache<NSString>(name: "AwesomeCache")
override func viewDidLoad() {
super.viewDidLoad()
textView.text = (cache["myText"] as? String) ?? ""
}
@IBAction func reloadData(sender: AnyObject?) {
textView.text = (cache["myText"] as? String) ?? ""
}
@IBAction func saveInCache(sender: AnyObject?) {
cache["myText"] = textView.text
}
@IBAction func calculateCacheSize(sender: AnyObject?) {
cache.calculateDiskCacheSizeWithCompletionHandler { (size) -> () in
let kSize = String(format: "%d", size)
print(kSize)
}
}
@IBAction func removeCache(sender: AnyObject) {
cache.removeAllObjects()
}
}