File tree Expand file tree Collapse file tree 3 files changed +50
-7
lines changed
SwiftJSONModeler For Xcode.xcodeproj/xcuserdata/yibin.xcuserdatad/xcdebugger
SwiftJSONModeler For Xcode Expand file tree Collapse file tree 3 files changed +50
-7
lines changed Original file line number Diff line number Diff line change 180180 landmarkType = " 7" >
181181 </BreakpointContent >
182182 </BreakpointProxy >
183+ <BreakpointProxy
184+ BreakpointExtensionID = " Xcode.Breakpoint.FileBreakpoint" >
185+ <BreakpointContent
186+ uuid = " FBB3965E-FAF3-47AF-A2E1-88A0A8B61F70"
187+ shouldBeEnabled = " Yes"
188+ ignoreCount = " 0"
189+ continueAfterRunningActions = " No"
190+ filePath = " SwiftJSONModeler For Xcode/Controller/ConfigViewController.swift"
191+ startingColumnNumber = " 9223372036854775807"
192+ endingColumnNumber = " 9223372036854775807"
193+ startingLineNumber = " 110"
194+ endingLineNumber = " 110"
195+ landmarkName = " saveButtonTap(_:)"
196+ landmarkType = " 7" >
197+ </BreakpointContent >
198+ </BreakpointProxy >
199+ <BreakpointProxy
200+ BreakpointExtensionID = " Xcode.Breakpoint.FileBreakpoint" >
201+ <BreakpointContent
202+ uuid = " 85E9C064-2E1F-4E79-9C30-B8A576B2887F"
203+ shouldBeEnabled = " Yes"
204+ ignoreCount = " 0"
205+ continueAfterRunningActions = " No"
206+ filePath = " SwiftJSONModeler For Xcode/Config/ConfigCenter.swift"
207+ startingColumnNumber = " 9223372036854775807"
208+ endingColumnNumber = " 9223372036854775807"
209+ startingLineNumber = " 18"
210+ endingLineNumber = " 18"
211+ landmarkName = " config"
212+ landmarkType = " 24" >
213+ </BreakpointContent >
214+ </BreakpointProxy >
183215 </Breakpoints >
184216</Bucket >
Original file line number Diff line number Diff line change @@ -13,12 +13,17 @@ let configPath = (NSHomeDirectory() as NSString).appendingPathComponent("Config
1313
1414class ConfigCenter {
1515 static let `default` = ConfigCenter ( )
16- var config : ConfigModel
16+ var config : ConfigModel {
17+ didSet { // 类赋值调用, 结构体直接改变属性也会调用
18+ Self . writeConfig ( config)
19+ }
20+ }
1721
1822 init ( ) {
1923 config = Self . readConfig ( )
2024 }
2125
26+
2227}
2328// MARK: - Private Static Method
2429
@@ -38,11 +43,16 @@ private extension ConfigCenter {
3843
3944 static func writeDefaultConfig( ) -> ConfigModel {
4045 let defaultConfig = ConfigModel ( )
46+ writeConfig ( defaultConfig)
47+ return defaultConfig
48+ }
49+ @discardableResult
50+ static func writeConfig( _ config: ConfigModel ) -> Bool {
4151 let propertyListEncoder = PropertyListEncoder ( )
4252 propertyListEncoder. outputFormat = . xml
4353
44- let plistData = try ? propertyListEncoder. encode ( defaultConfig )
45- _ = FileManager . default. createFile ( atPath: configPath, contents: plistData, attributes: nil )
46- return defaultConfig
54+ let plistData = try ? propertyListEncoder. encode ( config )
55+ let isSuccess = FileManager . default. createFile ( atPath: configPath, contents: plistData, attributes: nil )
56+ return isSuccess
4757 }
4858}
Original file line number Diff line number Diff line change 88
99import Cocoa
1010
11-
12-
1311class ConfigViewController : NSViewController {
1412
1513 private let config = Config ( )
@@ -108,7 +106,10 @@ class ConfigViewController: NSViewController {
108106 }
109107
110108 @IBAction func saveButtonTap( _ sender: NSButton ) {
111-
109+ let config = ConfigCenter . default
110+ var c = config. config
111+ c. appVersion = " 2.1.0 "
112+ config. config = c
112113// config.conform = confromTextField.stringValue
113114// config.module = moduleTextField.stringValue
114115// config.prefix = prefixTextField.stringValue
You can’t perform that action at this time.
0 commit comments