• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

macOSのスクリーンショットの保存場所を変更するメニュバーエクストラ


Commit MetaInfo

Revision3c821ea2544a20c1612860ee46a9b7c2d21efea2 (tree)
Time2017-04-23 11:39:05
Authormasakih <masakih@user...>
Commitermasakih

Log Message

UserDefaultsにRecentFolderを保存できるようにした

Change Summary

Incremental Difference

--- a/GoInto.xcodeproj/project.pbxproj
+++ b/GoInto.xcodeproj/project.pbxproj
@@ -13,7 +13,9 @@
1313 F40EB6CA1EA1D7B500FEE444 /* ImageType.plist in Resources */ = {isa = PBXBuildFile; fileRef = F40EB6C91EA1D7B500FEE444 /* ImageType.plist */; };
1414 F40EB6D01EA26BEC00FEE444 /* ActionListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40EB6CF1EA26BEC00FEE444 /* ActionListener.swift */; };
1515 F40EB6D21EA2F28100FEE444 /* Screenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40EB6D11EA2F28100FEE444 /* Screenshot.swift */; };
16+ F414DD031EABAB7300111DA7 /* UserDefaultsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD021EABAB7300111DA7 /* UserDefaultsExtension.swift */; };
1617 F414DD051EAC12D500111DA7 /* FolderItemSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD041EAC12D500111DA7 /* FolderItemSerializer.swift */; };
18+ F414DD071EAC43E500111DA7 /* UserDefaultsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */; };
1719 F463F6D91EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */; };
1820 F463F6DB1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F463F6DA1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift */; };
1921 F47B06EB1E9A5DF9006711D9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B06EA1E9A5DF9006711D9 /* AppDelegate.swift */; };
@@ -48,7 +50,9 @@
4850 F40EB6C91EA1D7B500FEE444 /* ImageType.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ImageType.plist; sourceTree = "<group>"; };
4951 F40EB6CF1EA26BEC00FEE444 /* ActionListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionListener.swift; sourceTree = "<group>"; };
5052 F40EB6D11EA2F28100FEE444 /* Screenshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screenshot.swift; sourceTree = "<group>"; };
53+ F414DD021EABAB7300111DA7 /* UserDefaultsExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtension.swift; sourceTree = "<group>"; };
5154 F414DD041EAC12D500111DA7 /* FolderItemSerializer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderItemSerializer.swift; sourceTree = "<group>"; };
55+ F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsTest.swift; sourceTree = "<group>"; };
5256 F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitedArraySerializerTest.swift; sourceTree = "<group>"; };
5357 F463F6DA1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitedArraySerializer.swift; sourceTree = "<group>"; };
5458 F47B06E71E9A5DF9006711D9 /* GoInto.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GoInto.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -109,6 +113,7 @@
109113 children = (
110114 F47B07071E9A6071006711D9 /* MainMenu.xib */,
111115 F47B06EA1E9A5DF9006711D9 /* AppDelegate.swift */,
116+ F414DD021EABAB7300111DA7 /* UserDefaultsExtension.swift */,
112117 F40EB6D11EA2F28100FEE444 /* Screenshot.swift */,
113118 F47B070D1E9A6E55006711D9 /* StatusBar.swift */,
114119 F47B070B1E9A65FA006711D9 /* StatusItem.swift */,
@@ -135,6 +140,7 @@
135140 children = (
136141 F4DBE9271EA7864B00CEB984 /* LimitedArrayTest.swift */,
137142 F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */,
143+ F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */,
138144 F47B06FC1E9A5DF9006711D9 /* GoIntoTests.swift */,
139145 F47B06FE1E9A5DF9006711D9 /* Info.plist */,
140146 );
@@ -257,6 +263,7 @@
257263 F47B070E1E9A6E55006711D9 /* StatusBar.swift in Sources */,
258264 F463F6DB1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift in Sources */,
259265 F4D346941EA644170031AFB3 /* LimitedArray.swift in Sources */,
266+ F414DD031EABAB7300111DA7 /* UserDefaultsExtension.swift in Sources */,
260267 F47B07121EA10A3E006711D9 /* ChooseFolderItem.swift in Sources */,
261268 F414DD051EAC12D500111DA7 /* FolderItemSerializer.swift in Sources */,
262269 );
@@ -266,6 +273,7 @@
266273 isa = PBXSourcesBuildPhase;
267274 buildActionMask = 2147483647;
268275 files = (
276+ F414DD071EAC43E500111DA7 /* UserDefaultsTest.swift in Sources */,
269277 F4DBE9281EA7864B00CEB984 /* LimitedArrayTest.swift in Sources */,
270278 F463F6D91EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift in Sources */,
271279 F47B06FD1E9A5DF9006711D9 /* GoIntoTests.swift in Sources */,
--- a/GoInto.xcodeproj/xcuserdata/masaki.xcuserdatad/xcschemes/GoInto.xcscheme
+++ b/GoInto.xcodeproj/xcuserdata/masaki.xcuserdatad/xcschemes/GoInto.xcscheme
@@ -26,7 +26,8 @@
2626 buildConfiguration = "Debug"
2727 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29- shouldUseLaunchSchemeArgsEnv = "YES">
29+ shouldUseLaunchSchemeArgsEnv = "YES"
30+ codeCoverageEnabled = "YES">
3031 <Testables>
3132 <TestableReference
3233 skipped = "NO">
--- /dev/null
+++ b/GoInto/UserDefaultsExtension.swift
@@ -0,0 +1,24 @@
1+//
2+// UserDefaultsExtension.swift
3+// GoInto
4+//
5+// Created by Hori,Masaki on 2017/04/23.
6+// Copyright © 2017年 Hori,Masaki. All rights reserved.
7+//
8+
9+import Foundation
10+
11+extension UserDefaults {
12+ var recentFolders: LimitedArray<FolderItem>? {
13+ get {
14+ guard let data = object(forKey: "recentFolders") as? Data,
15+ let serialized: LimitedArray<FolderItem> = LimitedArraySerializer.deserialize(data)
16+ else { return nil }
17+ return serialized
18+ }
19+ set {
20+ let data = newValue.map { LimitedArraySerializer.seirialize($0) }
21+ set(data, forKey: "recentFolders")
22+ }
23+ }
24+}
--- /dev/null
+++ b/GoIntoTests/UserDefaultsTest.swift
@@ -0,0 +1,30 @@
1+//
2+// UserDefaultsTest.swift
3+// GoInto
4+//
5+// Created by Hori,Masaki on 2017/04/23.
6+// Copyright © 2017年 Hori,Masaki. All rights reserved.
7+//
8+
9+import XCTest
10+
11+@testable import GoInto
12+
13+class UserDefaultsTest: XCTestCase {
14+
15+ func testRecentFolders() {
16+ var limited = LimitedArray<FolderItem>(3)
17+ limited.append(FolderItem(URL(fileURLWithPath: "/System/")))
18+ limited.append(FolderItem(URL(fileURLWithPath: "/Users/")))
19+ limited.append(FolderItem(URL(fileURLWithPath: "/var/")))
20+
21+ UserDefaults.standard.recentFolders = limited
22+
23+ let storedData = UserDefaults.standard.recentFolders
24+ XCTAssertNotNil(storedData)
25+ guard let stored = storedData else { return }
26+
27+ XCTAssertEqual(limited.array, stored.array)
28+ XCTAssertEqual(limited.size, stored.size)
29+ }
30+}