@@ -24,7 +24,7 @@ class ViewController: NSViewController {
24
24
@IBOutlet weak var jsonTypeBtn : NSPopUpButton !
25
25
@IBOutlet weak var generateFileBtn : NSButton !
26
26
27
- var outputFilePath : String ?
27
+ /// cache key
28
28
29
29
let LastInputURLCacheKey = " LastInputURLCacheKey "
30
30
let SuperClassNameCacheKey = " SuperClassNameCacheKey "
@@ -35,6 +35,11 @@ class ViewController: NSViewController {
35
35
let SupportJSONModelTypeCacheKey = " SupportJSONModelTypeCacheKey "
36
36
let ShouldGenerateFileCacheKey = " ShouldGenerateFileCacheKey "
37
37
let GenerateFilePathCacheKey = " GenerateFilePathCacheKey "
38
+
39
+ /// cache key
40
+ var outputFilePath : String ?
41
+
42
+ var builder = SKCodeBuilder ( )
38
43
39
44
override func viewDidLoad( ) {
40
45
super. viewDidLoad ( )
@@ -57,7 +62,9 @@ class ViewController: NSViewController {
57
62
loadUserLastInputContent ( )
58
63
}
59
64
65
+ /// load cache
60
66
func loadUserLastInputContent( ) {
67
+
61
68
if let lastUrl = UserDefaults . standard. string ( forKey: LastInputURLCacheKey) {
62
69
urlTF. stringValue = lastUrl
63
70
}
@@ -77,6 +84,19 @@ class ViewController: NSViewController {
77
84
outputFilePath = outFilePath
78
85
}
79
86
87
+ builder. config. codeType = SKCodeBuilderCodeType ( rawValue: UserDefaults . standard. integer ( forKey: BuildCodeTypeCacheKey) ) ?? . OC
88
+ codeTypeBtn. selectItem ( at: builder. config. codeType. rawValue - 1 )
89
+
90
+ builder. config. jsonType = SKCodeBuilderJSONModelType ( rawValue: UserDefaults . standard. integer ( forKey: SupportJSONModelTypeCacheKey) ) ?? . None
91
+ jsonTypeBtn. selectItem ( at: builder. config. jsonType. rawValue)
92
+
93
+ generateFileBtn. state = UserDefaults . standard. bool ( forKey: SupportJSONModelTypeCacheKey) ? . on : . off
94
+ }
95
+
96
+ /// save cache
97
+ func saveUserInputContent( ) {
98
+ let superClassName = superClassNameTF. stringValue. isBlank ? " NSObject " : superClassNameTF. stringValue
99
+ UserDefaults . standard. setValue ( superClassName, forKey: SuperClassNameCacheKey)
80
100
}
81
101
82
102
0 commit comments